simonhaenisch / md-to-pdf

Hackable CLI tool for converting Markdown files to PDF using Node.js and headless Chrome.
https://www.npmjs.com/md-to-pdf
MIT License
1.18k stars 111 forks source link

feature: add language to body-tag #274

Open swidbert opened 10 months ago

swidbert commented 10 months ago

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.

simonhaenisch commented 10 months ago

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

simonhaenisch commented 10 months ago

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?

swidbert commented 9 months ago

No, that's not the problem. HTML expects the language code to be able to use hyphenation correctly.

Am Mo., 27. Nov. 2023 um 13:48 Uhr schrieb Simon Hänisch < @.***>:

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?

— Reply to this email directly, view it on GitHub https://github.com/simonhaenisch/md-to-pdf/issues/274#issuecomment-1827771314, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABAG2YPZVENW2MDNXBF7ITTYGSDZJAVCNFSM6AAAAAA7YB3PTOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRXG43TCMZRGQ . You are receiving this because you authored the thread.Message ID: @.***>