simonhaenisch/md-to-pdf

feature: add language to body-tag

swidbert opened this issue · 3 comments

Problem:

To be able to use hyphenation correctly in the German language, the "html" tag requires the "lang" attribute. The "lang" attribute determines which language the element content uses.

Solution:

To do this, simply adjust line 9 in the "get-html.js" file:

<html${config.body_lang ? ` lang="${config.body_lang}"`: ''}>

To activate this in HTML files, this would then be possible by passing the parameter body_lang: 'de' in the options.

Ok sure do you want to create a PR? I won't have time for it any time soon.

  • make the change you suggested in get-html.ts
  • add the option in config.ts into BaseConfig interface and defaultConfig object
  • add it in cli.ts after --body-class as a CLI flag
  • add it in help.ts after --body-class with a description
  • update the readme (usage and options)

BTW the problem with your hyphenation could also just be that you're not saving the file with UTF-8 as file encoding? Have you tried --md-file-encoding flag?