Better handle mid-word asterisks (for gender-neutral German)

Use case or problem

I often need to use asterisks ( * ) or colons ( : ) inside of words. This is mainly used for gender-inclusive writing in German. (I know this is a contentious topic, but let’s try to keep politics out of it and assume for some reason or another I have to edit markdown files with this writing style.)

Unfortunately, Obsidian (like most Markdown implementations) consider an asterisk inside of a word to start italics: Bäcker*innen becomes “Bäcker*innen” in the editor and “Bäckerinnen” in the preview.

Current workarounds

The workarounds are all not very satisfying:

Some people have adopted the colon as an alternative: “Bäcker:innen”. It looks less obstrusive and is handled better by markdown implementations and screen readers. However, sometimes the style guide requires the asterisk. Also, I’ve noticed Obsidian sometimes converts words with colons into links, like “Soldat:innen”

You can also escape the asterisk with a backslash, Bäcker\*innen, but Obsidian highlights the backslash in orange and dims out the asterisk. This makes the backslash even more prominent. It also inserts a second asterisk as if you are creating italics.

Proposed solution

A minimal solution would be to fix the syntax highlighting for \*: Dim the backslash, and make the asterisk the normal color.

A possible solution would be to have an option to disable the asterisk mid word, either globally or by using some magic annotation in the file. But I don’t like the idea of creating yet another markdown dialect.

The best solution IMO would be a plugin that transparently inserts the escape characters (combined with the syntax highlight fix). For example:

  • If you are at the end of a word and press *, it inserts an asterisk.
  • If you then press another non-space character, it changes the * to \*
  • If you press backspace after \*, it removes both together.

The tricky thing would be to get all the edge cases right, but I think it is doable.

Related feature requests (optional)

Essentially the clash is between the established markdown usage and the new German usage.
Obsidian’s way of dealing with such clashes in other situations is to escape the character, which you don’t think is suitable here.

I think this makes it a plugin request rather than a feature request.
Probably the best way of dealing with it since there may well be similar situations with other languages in the future. Maybe a German coder who understands the nuances would be able to take it forward?

1 Like

@captainmuon You can implement your proposed minimal solution by means of the following css snippet:

/***************************************/
/*         Escape backslash            */
/***************************************/

span.cm-hmd-escape-backslash {
  ; color: rgb(030,140,250) !important;  /* ← Edit numeric RGB values to change color of backslash */
}

span.cm-hmd-escape-char {
  ; color: rgb(230,140,050) !important;  /* ← Edit numeric RGB values to change color of escaped char */
}

Copy it into text editor and save as YourPreferedFilename.css according to guide for dealing with CSS snippets, available here: Add custom styles
Then play with numeric values to fit your taste. After saving the changes to css file, they should be immediately visible in Obsidian.

1 Like

Thanks, the CSS fix helps already a bit! I’ll check out how to write an extention if I have a bit of time.