Problem with Scrivener’s Text Replacement in LaTeX

There are two things to consider:

  • Firstly, MMD has native support for CriticMarkup, which it will convert to Soul markings by default. The stock compile Formats have CM styles set up, such as “Highlight”.

  • If you want to roll your own though, and use Soul markup directly, you need to use the pass-thru syntax to let MMD know that what you’re doing isn’t writing about how to use LaTeX. :wink: The markup for that is similar to a code span, but with {=latex} on the end of it, like so:

    `\hl{`{=latex}
    

    And similar for the suffix. Since you are passing LaTeX straight through, you don’t need to escape special characters like the backslash. The same convention is there for fenced block quotes, putting the language suffix on the end of the opening triple-backtick line.

    As you might guess, you can use a variety of targets in there other than ‘latex’. It’s a useful way of passing raw markup to different outputs while completely excluding them from others. You might want to do something with {=html} as well for your highlight, and you can pack all of that into your style prefix and suffix (or create different Formats for different targets to keep it cleaner).

2 Likes