FMHYedit/.vitepress/markdown/toggleStarred.ts

12 lines
403 B
TypeScript
Raw Normal View History

2023-11-12 13:39:41 +05:30
import type { MarkdownRenderer } from "vitepress";
export function toggleStarredPlugin(md: MarkdownRenderer) {
md.renderer.rules.list_item_open = (tokens, index, options, env, self) => {
const contentToken = tokens[index + 2];
if (contentToken && contentToken.content.startsWith("⭐")) {
return `<li class="starred">`;
}
return self.renderToken(tokens, index, options);
};
}