[Fixed] HTML generated from Markdown should set lang attribute

When DT creates HTML from Markdown (either explicitly with the “convert to” function or implicitly when previewing MD), the html element does not contain a lang attribute. It does, however, set the dir attribute to auto, thus burdening the browser with determining the writing direction.

In my opinion, DT should set the lang attribute and a meaningful dir value when converting MD to HTML.

  1. lang is required for assistive technologies – without it, a screen reader wouldn’t know which language the document is written in, which makes reading it kind of difficult.
  2. lang is required by the browser if the user wants hyphenated text. Without knowing the language, hyphenation is not possible.

As a default, the lang attribute could be deduced from the system-wide locale. As Multimarkdown 6 provides for a Language metadata key, the user should be able to use that if they want to override the default. That way, a user could indicate that a particular MD file is written in (eg) French, although their system-wide locale is (eg) German.

This has been fixed in DT 3.9.7: The lang attribute is derived from the language metadata in the MD’s front matter. Missing that, the system-wide setting is used.

:+1:

1 Like