marp-team / marp-vscode

Marp for VS Code: Create slide deck written in Marp Markdown on VS Code
https://marketplace.visualstudio.com/items?itemName=marp-team.marp-vscode
MIT License
1.55k stars 72 forks source link

Add support for `lang` directive #430

Closed ludelafo closed 10 months ago

ludelafo commented 1 year ago

Hi Marp team!

I'm interested to use the hyphens CSS property as follow:

theme: gaia
style: |
    p {
        hyphens: auto;
    }

In order for this to work, I need to set the lang attribute.

marp-cli defines the argument lang in its options. When using the command-line tool as npx @marp-team/marp-cli@latest --lang en --pdf --output README.pdf README.md, the hyphens are correctly rendered.

I would like to add support for the lang directive in marp-vscode so the language of the document can be set:

theme: gaia
lang: en
style: |
    p {
        hyphens: auto;
    }

From my understanding of the codebase, the starting point would be https://github.com/marp-team/marp-vscode/blob/d9af184ed12b65bb28c0f328e250955d548ac1d1/src/directives/definitions.ts by adding a new directive such as:

  // Marp CLI metadata options
  createDirectiveInfo({
    name: 'lang',
    description: 'Set lang of the slide deck.',
    allowed: directiveAlwaysAllowed,
    providedBy: DirectiveProvidedBy.MarpCLI,
    type: DirectiveType.Global,
    details: 'https://github.com/marp-team/marp-cli#metadata', // Need to update the metadata as well
  }),

Would this feature be useful for marp-vscode? I would be glad to implement this feature if you are interested.

yhatt commented 1 year ago

If so, the starting point would be Marp CLI rather than Marp for VS Code. Could you create an Issue in the Marp CLI repository to propose implementing lang global directive? https://github.com/marp-team/marp-cli/issues

ludelafo commented 10 months ago

Thank you very much @yhatt!