Code Formatting

Hello!
I’m exporting notes with code from Obsidian. How can I set up blocks of code, namely:

You can wrap your whole code section in html <pre><code>{{MyCodeField}}</code></pre> using the “edit notetype” button.

You can then style the background using css in the styling section:

pre {
	background-color: black;
}

code {
	font-family: "FreeMono";
}

Regarding the font, either choose a monospace font that is preinstalled on your operating system, or follow the instructions in the documentation to install your preferred monospace font.

For further styling, read this blog post by Arthur Milchior: Syntax coloring of code in Anki - Arthur Milchior's personal blog

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.