Anki Forums

Double backslashes in text of notes are turned into single backslashes on display

This happens on both Anki desktop and AnkiMobile (latest stable desktop on Manjaro Linux installed through the official package on apps.ankiweb.net, latest beta AnkiMobile on iPhone XS installed through TestFlight).

If I use four backslashes in the editor, two backslashes appear in the output. So this isn’t a big deal, but it doesn’t look intentional.

This seems to occur only in fairly specific circumstances:

  • A single backslash displays normally.
  • Standard backslash escapes like \n also display normally (appear literally in the output).
  • The bit within syntax highlighting markup doesn’t appear to be affected, perhaps because it is in <pre> tags.

This started happening sometime in the last few versions, though I am not sure exactly when. If this doesn’t ring a bell for anyone, I can try bisecting to find where it started.

HTML of the note shown above in case you have trouble reproducing:

Front side:

What is wrong with the following Sphinx markup?<div><table class="highlighttable"><tbody><tr><td><div class="linenodiv" style="background-color: #f0f0f0; padding-right: 10px"><pre style="line-height: 125%">1</pre></div></td><td class="code"><div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%">Name the file <span style="color: #7D9029">:file:</span><span style="color: #19177C">`C:\\Users\\{your username}\\myfile.txt`</span>.
</pre></div>
</td></tr></tbody></table></div>

Back side:

Before a brace, you must use <i>four </i>backslashes to get a single output backslash (\ is an escape character for reStructuredText, and \\ is an escape character for the definition of the <i>file</i>&nbsp;role).
1 Like

Thanks, I’ve pushed a fix.

1 Like