jupyter-book / mystmd

Command line tools for working with MyST Markdown.
https://mystmd.org/guide
MIT License
213 stars 63 forks source link

enable language to be specified and propagate this to the myst site #314

Open stevejpurves opened 1 year ago

stevejpurves commented 1 year ago

Which area is this feature request for?

Website User Interface, Command Line Tools, MyST Markdown Syntax

Describe the feature you'd like to request

Adding the document language will allow the lang attribute to be appropriately set for the whole document.

This improves accessibility and allows screen readers to react to the language properly.

See https://www.boia.org/blog/why-language-is-important-for-web-accessibility

Describe the solution you'd like

Also should we define lang as an attribute on a thematic break? a lang directive and lang role? Allowing block and inline content to also be tagged with the language

Describe alternatives you've considered

No response

lduktus commented 1 year ago

Hi, I would like to add my thoughts on this, however as I said I am not an expert in the field:

Besides defining the document language in the front matter, I think it makes sense to implement a way to change the language of arbitrary content inside the document. In HTML this would be reflected by <span lang="">

In LaTeX at least Babel has this functionality, too, but if I remember right the languages need to be loaded in the Preambel.

Pandoc Markdown also has a syntax for this, using native Divs and Spans:

::: {lang=es-ES}
Español
:::

The thing I don't like about this is that the syntax nudges you to separate languages by paragraphs. But there are a lot of scenarios where you may want to write different languages without breaking your text flow, e.g. for technical terms, concepts or partial quotes.

You already mentioned the accessibility aspect. In a lot of CMS I tried, this is completely ignored. Besides this, it also helps when publishing to PDF, as hyphenation rules may differ. As far as I am aware of, LaTeX does this semi-automagically when configuring the according packages properly.

Additionally, language information could also help to create additional ways of interactivity when publishing to the web, as it may help to build frontends that allow to toggle between translations, etc. Which would be awesome for a lot of scientific disciplines.

EDIT: Forgot code fences around the span...