Convert backticks to HTML <code>
tags in the Anki editor.
This makes the Anki editor parse backticks as Markdown.
`x == 2`
) will be converted like so <code>x == 2</code>
.```x == 2```
) will be converted like so <pre><code>x == 2</pre></code>
.Append a newline-delimited, alphanumeric string to a triple backtick to add a class.
\```php
echo "hi";
\```
(Note the newline after php
!) This will be converted to:
<pre><code class="language-php">echo "hi";</code></pre>
Also works with <br>
instead of "raw" newline, since the Anki editor automatically inserts <br>
\```php<br>
echo "hi";
\```
Many popular JS-based syntax highlighters (highlight.js, prismjs) can automatically detect what language you're using, but sometimes you have to be explicit and specify the language yourself.
FWIW, to install a syntax highlighter:
collection.media
directory (for example, highlight.min.js
)_
(for example, highlight.min.js
-> _highlight.min.js
)
_
(e.g., _github-dark.min.css
)<link rel="stylesheet" href="https://github.com/dempe/anki-easy-code-tags/blob/main/_github-dark.min.css">
<script src="https://github.com/dempe/anki-easy-code-tags/raw/main/_highlight.min.js"></script>
<script>hljs.highlightAll();</script>