Note-specific language setting?

Dear Obsidian community!
Thank you for having me :smiley: . I’ve been using Obsidian for a bit over a year now and have become a huge fan. I really love working with it, customising it, and collecting my thoughts and ideas in it.

Every now and then I come across things I’m trying to improve but don’t know how. Now I was wondering if any of you could help me with the following:

What I’m trying to do

Whenever I type a double-quote (") in a note, I want it to be replaced automatically with the correct typographical quote. However, opening and closing typographical quotes are different depending on the language I’m writing in:

  • English: “text”
  • German: „text“
  • French: « text »

In CSS it possible to specify language-sensitive quotes via the <q> tag:

:lang(de) {quotes: "\201E" "\201C" "\201A" "\2018";}
:lang(en) {quotes: "\201C" "\201D" "\2018" "\2019";}
:lang(fr) {quotes: "\AB\2005" "\2005\BB" "" "";}
:lang(fr) q q {font-style: italic;}

If I define this CSS code as a snippet and insert the html <q> tags in a note (via the Wrap with shortcuts plugin), the typographical quotes do work—but their language is taken from the language setting of the vault and not of the individual note. However, I write notes in English and German in the same vault.

Is it possible to set the language for an individual note (maybe in a property) so that CSS recognises it as lang attribute?

Things I have tried

  • There is a plugin Smart Typography: it’s disadvantage is that I can only specify typographical quotes for the whole vault and not language dependent.
  • I can add the lang attribute to the individual <q> tag in the note: <q lang=de>text</q>
    This is quite cumbersome, though, and defeats the purpose of making things easier when typing text.
  • I already tried adding a lang property with the value de to a note but that property is not being picked up by the CSS code.

Thanks so much for any help you might be able to offer!
C

You can use cssclasses with the HTML <q> tag.

Make this CSS snippet:

.de {quotes: "\201E" "\201C" "\201A" "\2018";}
.en {quotes: "\201C" "\201D" "\2018" "\2019";}
.fr {quotes: "\AB\2005" "\2005\BB" "" "";}
.fr q q {font-style: italic;}

In the note, add the cssclasses property and give it the class name (which we’ve set the same as the two-character language identifier):

---
cssclasses:
  - fr
---

<q>bonjour</q>
1 Like

Thanks so much, dawni! That’s brilliant :star_struck:

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