Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for lang directive #542

Closed
ludelafo opened this issue Aug 21, 2023 · 3 comments · Fixed by #558
Closed

Add support for lang directive #542

ludelafo opened this issue Aug 21, 2023 · 3 comments · Fixed by #558
Labels
enhancement New feature or request

Comments

@ludelafo
Copy link

In order to use the hyphens CSS property as mentioned in marp-team/marp-vscode#430, a new lang global directive must be implemented.

A starting point would be https://github.com/marp-team/marp-cli/blob/d0cee502f2785e1a2f998f3afc831849e3f6efc9/src/marp-cli.ts and https://github.com/marp-team/marp-cli/blob/d0cee502f2785e1a2f998f3afc831849e3f6efc9/src/engine/meta-plugin.ts by adding a lang directive.

I see at

html(lang=lang)
that the HTML lang is set here. If I understand it correctly, this value is passed by the --lang argument of the CLI where a new global directive should also set this value if set.

Please correct me if I'm wrong. I would be glad to implement this feature if you are interested.

@yhatt yhatt added the enhancement New feature or request label Aug 21, 2023
@yhatt
Copy link
Member

yhatt commented Aug 23, 2023

Currently Marp CLI uses the locale of running OS as the value for the lang attribute of the <html> element.

lang: this.conf.lang || (await osLocale()).replace(/@/g, '-'),

Unlike similar options for metadata, the CLI argument --lang is not supported in the current Marp CLI, and changes are only supported in the lang field of the configuration file. Therefore, it may be a little hard to contribute for that.

This decision was made to prevent unnecessary confusion for not specialized users. Providing an easily changeable CLI option / global directive might lead unintended rendering output and a bit of confusion, especially in East Asian languages.
https://heistak.github.io/your-code-displays-japanese-wrong/

However, considering the appropriate purpose of "document-level language setting", adding --lang option and the lang global directive support would be justified.

@yhatt
Copy link
Member

yhatt commented Sep 25, 2023

This issue may be best drilling down to Marp Core, and even Marpit, the framework to build a core.

The lang attribute can be used on any tag, not just <html>. Given that the snippets of slides generated by Marp are also used by third-party implementations outside of the official Marp tools, so it is better to have the lang attribute on each slide tags, rather than the <html> tag. (Note that it's not meaning to remove lang attribute from <html> provided by Marp CLI templates)

If there were lang attribute in each slide, the display reproducibility of the slide in cases where multiple languages are mixed in a single HTML. e.g. a web page/app with Marp slides as a part of HTML.

@ludelafo
Copy link
Author

Thank you very much @yhatt!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants