shaku-code-annotate
v0.1.4
Published
<ruby>釈<rp>(<rp><rt>Shaku</rt><rp>)<rp></ruby>- _elucidate, explain_
Downloads
10
Readme
shaku-code-annotate
釈(Shaku)- elucidate, explain
This module enables you to annotate your code snippet with separation from normal comments, makes it easier to explain the code. It uses shiki as backbone and inspired by shiki-twoslash.
Take a look at the live demo from
Usage
import { getShakuHighlighters } from "shaku-code-annotate";
// 1. get highlighters of one theme or multiple themes
const highlighters = await getShakuHighlighters({
langs: [lang],
// theme: 'github-light'
themes: ["github-light", "github-dark"],
});
// 2. for each theme generate HTML from code
const html = highlighters
.map(
(highlighter) =>
highlighter.codeToShakuHtml({
code,
meta: "annotate",
// by default Shaku falls back to shiki if meta doesn't contain "annotate"
// you can turn this off by following option
// fallbackToShiki: false
parseBasicMarkdown: (code) => code,
options: {
lang,
},
}).html
)
.join("\n");
Plugins
Generally it is better for you to choose the right plugin for your markdown engine.
- Remark - remark-shaku-code-annotate
- Marked - marked-shaku-code-annotate