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 Custom Language Grammars in processMarkdown #11

Closed
jasonnathan opened this issue Sep 22, 2024 · 1 comment · Fixed by #12
Closed

Add Support for Custom Language Grammars in processMarkdown #11

jasonnathan opened this issue Sep 22, 2024 · 1 comment · Fixed by #12

Comments

@jasonnathan
Copy link
Contributor

jasonnathan commented Sep 22, 2024

Hey there, I initially thought about forking the package to add a small feature but decided it would be cleaner to refactor it a little instead. I've already created a PR with the changes but thought I'd open an issue first to discuss.

I've added support for consumers of the package to pass custom language grammars via a langConfig option. This allows extending the syntax highlighting without modifying the core library.

Usage

import langLua from "shiki/langs/lua.mjs";

const { html } = processMarkdown({
  md: mdWithLua,   // Your markdown string with Lua code blocks
  langConfig: {
    langs: [langLua],  // Add custom Lua language grammar
    // aliases: {} can be added too if needed
  },
});

If this feature aligns with the direction of the project, I’d be happy to finalise the pull request. Let me know if you'd like any changes.

Thanks for considering!

@jasonnathan jasonnathan changed the title Add Support for Custom Language Grammars in processMarkdown Add Support for Custom Language Grammars and Optional Frontmatter in processMarkdown Sep 22, 2024
@jasonnathan jasonnathan changed the title Add Support for Custom Language Grammars and Optional Frontmatter in processMarkdown Add Support for Custom Language Grammars in processMarkdown Sep 22, 2024
@rossrobino
Copy link
Owner

Great idea! Thanks for making the PR I'll take a look

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

Successfully merging a pull request may close this issue.

2 participants