rossrobino / robino

JS modules
MIT License
0 stars 1 forks source link

Add Support for Custom Language Grammars in processMarkdown #11

Open jasonnathan opened 5 hours ago

jasonnathan commented 5 hours ago

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!

rossrobino commented 3 hours ago

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