In Ulysses, code examples are set in a monospaced typeface (what else would make sense for a code block?) on a colored background (depending on the theme).
There are two different ways to mark up code in Ulysses:
First, you can use the inline code tags for smaller code snippets within a sentence. Just tag the beginning and the end of the respective code with a single backtick `. On iOS, the tag can be found by tapping A| in the button row above the on-screen keyboard.
You are probably wondering if Ulysses’ code blocks are compatible with GFM code blocks, despite the different amount of backticks. The answer is: Yes! If you import a Markdown document containing GFM code blocks, Ulysses automatically converts them. It also works the other way around: Export any sheet as a Markdown file and you’ll get proper GFM code blocks in your output.
Converting also works with Ulysses’ copy and paste options, which you’ll find in the Edit menu. Or use the following shortcuts:
And the best thing is: Code blocks are available for Markdown files in external folders as well. When editing a Markdown file that lives in a folder outside of Ulysses, you can use fancy code blocks while writing, but Ulysses writes out GFM fenced code blocks. Very convenient!
Programmers use syntax highlighting to improve the clarity and legibility of their code. Ulysses’ code blocks support syntax highlighting for the most common programming and markup languages.
The color scheme used in Ulysses is derived from GitHub. If you’re a Mac user, you can also create your own Ulysses style and change the colors according to your taste and needs.
Here is a short overview of the steps you need to take for creating a PDF/DOCX export style with custom syntax highlighting:
Or did you already customize a style in the past and would like to integrate syntax highlighting? Simply copy the syntax highlighting section from the duplicate and paste it at the end of your own style sheet. Save the ULSS file, and the code blocks in your exported sheets will be highlighted accordingly.