jgm / djot

A light markup language
https://djot.net
MIT License
1.62k stars 43 forks source link

Support `<dfn>`, `<cite>` and `<i>`? #287

Open rauschma opened 3 months ago

rauschma commented 3 months ago

Semantic HTML distinguishes the following kinds of italics:

  1. Emphasizing text (which affects how you’d read it out loud):

    Now <em>that</em> is a good idea.
  2. Definition (introducing new terms):

    A <dfn>bicycle</dfn> is a vehicle with two wheels.
  3. Citing names, book titles, etc.:

    I enjoyed <cite>His dark materials</cite>.
  4. Mentioning foreign-language text:

    She said <i lang="fr">au revoir</i>.

Would it make sense to support some of #​2–#​4 in djot? It would make the generated HTML more semantic. Options include:

{:dfn text:}
::dfn text::

{"cite text"}
""cite text""
Omikhleia commented 3 months ago

1-3 look like #240 could address them.

4 seems different and already doable, no? (_au revoir_{lang=fr}, with or without explicit span) (EDIT: The <i> in your example doesn't seem very semantic though... Should rather be a <span>, no?)

rauschma commented 3 months ago

The <i> in your example doesn't seem very semantic though... Should rather be a <span>, no?

This is what the HTML spec says (emphasis in bold is mine):

“The i element represents a span of text in an alternate voice or mood, or otherwise offset from the normal prose in a manner indicating a different quality of text, such as a taxonomic designation, a technical term, an idiomatic phrase from another language, transliteration, a thought, or a ship name in Western texts.”

“Terms in languages different from the main text should be annotated with lang attributes [...]”

1-3 look like #240 could address them.

True! Maybe:

!dfn[dfn text]
!cite[cite text]
!i[i text]{lang="fr"}

Or, more verbose:

[dfn text]{!dfn}
[cite text]{!cite}
[i text]{!i lang="fr"}