feat: support markdown
This commit is contained in:
parent
bd230ddd4f
commit
85d144a1e9
34 changed files with 2350 additions and 4 deletions
20
ui/components/Markdown/parser/index.ts
Normal file
20
ui/components/Markdown/parser/index.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { Paragraph, ParagraphType, Root, TextType } from "@yozora/ast";
|
||||
import { GfmExParser as Parser } from "@yozora/parser-gfm-ex";
|
||||
|
||||
export const parser = new Parser({
|
||||
defaultParseOptions: {
|
||||
shouldReservePosition: false,
|
||||
},
|
||||
});
|
||||
|
||||
export const hasHighlightContent = (content: string): boolean => {
|
||||
const data: Root = parser.parse(content);
|
||||
if (data.children.length === 0) return false;
|
||||
for (const node of data.children) {
|
||||
if (node.type !== ParagraphType) return true;
|
||||
|
||||
const paragraph = node as Paragraph;
|
||||
if (paragraph.children.some(v => v.type !== TextType)) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue