syntax highlights in org-mode html export - org-mode

my question might be very simple, but I did'nt find any answer available on the web.
How to pygmentize code blocks in org-mode HTML export ? I have some code blocks like this :
#+BEGIN_SRC puppet
file{'/etc/motd':
ensure => present,
content => 'Bienvenue !',
}
#+END_SRC
The exported html is not highlighted, however pygments is able to colorize puppet code.

I found out that you need the htmlize.el package installed. Then, it works out of the box.
htmlize.el is available in MELPA for instance.

Related

Grammar checker in VS CODE

I need to check the grammar of various docstrings, is there a way to do that directly in Visual Studio Code (or any other editor) without copying and pasting each docstring in a grammar checker like Grammarly?
At the bottom of the extension settings for Grammarly, under Grammarly>Files: Include you could add python files to be checked, by adding:
**/*.py
Note, this would include the whole python file and not just the docstrings.

Make new command in .ipynb markdown in VSCode

I am trying to create new commands for markdown in an ipython notebook file in VSCode, but am having trouble doing so
This post shows an example which (kinda) works in jupyter notebook:
$\newcommand{\vect}[1]{{\mathbf{\boldsymbol{{#1}}}}}$
This is the vector $\vect{x}$.
But pasting this exact code in VSCode, I get the error:
ParseError: KaTeX parse error: Undefined control sequence: \vect at position 1: \vect{x}.
So it seems the new command does not get created. Am grateful for any solution
Issue 125425 opened by Chandresh Pant and mentioned in the comments seems to be solved for VSCode 1.69 (June 2022)
See PR 148006 and commit acb156d:
In order to make macros defined by the author persistent between KaTeX elements, we need to pass one shared macros object into every call to the renderer.
KaTeX will insert macros into that object and since it continues to exist between calls, macros will persist.
See KaTeX docs.
Try the Markdown + Math extension by Stefan Goessner which supports macros. It works really well on my setup.
We can also define macros in the user settings, e.g.
"mdmath.macros": {
"\\vect" "{\\mathbf{\\boldsymbol{{#1}}}}"
}
or in a separate json file as follows.
"mdmath.macroFile": "/path/to/macros.json"

.ejs formatting in VSCode

This is my problem - its unreadable
In order to get .ejs working in general, I've so far added the following. I also have format on save and prettier. I'm looking for proposals to get better formatting of this so that I can read it.
"files.associations": {
"*.ejs": "html",
"*.css": "postcss"
},
"emmet.includeLanguages": {
"postcss": "css",
"ejs": "html"
},
"emmet.syntaxProfiles": {
"postcss": "css",
"ejs": "html"
}
I know that's an old question, but working with .ejs in VSCode is still a problem. But I found the solution (for ? delimeter)
Install EJS language support plugin
Now you have ejs support, highlighting, and snippets, but some tags like
<? for( let item of array ) { ?>
(some data)
<? } ?>
are formatted incorrectly (at least with default html formatter).
To fix this, you can try set custom delimeter to '?' ejs.delimeter = '?'. Now you have correct indentation with <? ... ?> tags.
To use the snippets with our custom delimeter, you need to edit extension snippets (or add your own): install Snippets Ranger plugin, then find needed extension and edit its file. The Snippets Ranger is very handy tool.
I hope I helped somebody to setup VSCode for .ejs files
I would suggest using
EJS language support
which is according to them
Syntax highlighting for EJS, Javascript, and HTML tags. Includes
javascript autocompletion.
and if you are interested in a Linter you should check out
EJS-Lint
which according to them
EJS-Lint parses scriptlet tags (<%, %>, <%_, _%>, and -%>). It ignores
all other tags (i.e. <%=).
Note: This linter does not attempt to check for unclosed EJS tags, so
if you get an error Unexpected token with a line number that doesn't
contain any scriptlets, you most likely forgot to close a tag earlier.
It also is set up to handle old-style includes (<% include filename
%>) by ignoring them. It does not lint included files regardless of
the method of inclusion.
It can work with custom delimiters, just pass it in the options (if
using the API) or pass the --delimiter (-d) flag on the CLI.

Neovims spell checking doesn't recognize the main word list if using spellfile

the spell checking in neovim has a strange behaviour. When I add a word to my own word list (de.utf-8.add, you see I'm a German) Neovim generates the de.utf-8.add.spl file for me. That's very nice and convenient. But after a restart of neovim, all words except the ones in my *.add file are marked as misspelled. It seems that neovim recognizes the de.utf-8.add.spl only. I use spell checking in the usual way:
:set spell spelllang=de_de
I put all my spell related file in:
~/.local/share/nvim/site/spell/
In my init.vim is nothing special:
set encoding=utf-8
set spellfile=~/.local/share/nvim/site/spell/de.utf-8.add
Because none has such a behaviour, I think, I did a stupid mistake. Could someone help me out of that.
I am using English and Japanese text.
In my environment, same bug was fixed with using
:set spell spelllang=en,cjk
Instead of
:set spell spelllang=cjk

Syntax Highlighting in iPython Notebook Markdown Cell

Is there a way to get a Markdown cell in iPython Notebooks to highlight syntax in code blocks?
For instance, in GitHub, one can get the desired effect via the following.
```python
>>>print('hello')
```
The GitHub Flavored Markdown-style of denoting code using the triple-backtick is now supported in IPython master branch on GitHub, and so will be included in the 1.0 release.
As Jakob noted, even prior to this, you could use regular markdown for code, in which you just need to indent your code by four spaces, and this continues to be a valid way of displaying code in your IPython notebook.
using IPython 0.13.1 syntax highlighting is as easy as (in a markdown cell):
some text
def foo():
print 'bar'
return 0
some text
Just, use a blank line before and indent the code (see example notebooks shipped with Ipython). This works for Python and some other languages.
In IPython 7.2.0 notebooks you can use:
Text `code` text
in a markdown cell to print highlighted code inline.