本文整理汇总了TypeScript中@textlint/markdown-to-ast.parse函数的典型用法代码示例。如果您正苦于以下问题:TypeScript parse函数的具体用法?TypeScript parse怎么用?TypeScript parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("should traverse", () => {
const AST: TxtParentNode = parse("# Header\n" + "Hello*world*");
const resultOfDump = dump(AST);
const expected = [
[enter, Syntax.Document, null],
// # Header
[enter, Syntax.Header, Syntax.Document],
[enter, Syntax.Str, Syntax.Header],
[leave, Syntax.Str, Syntax.Header],
[leave, Syntax.Header, Syntax.Document],
// => Paragraph
[enter, Syntax.Paragraph, Syntax.Document],
[enter, Syntax.Str, Syntax.Paragraph],
[leave, Syntax.Str, Syntax.Paragraph],
// *world*
[enter, Syntax.Emphasis, Syntax.Paragraph],
[enter, Syntax.Str, Syntax.Emphasis],
[leave, Syntax.Str, Syntax.Emphasis],
[leave, Syntax.Emphasis, Syntax.Paragraph],
// <= Paragraph
[leave, Syntax.Paragraph, Syntax.Document],
// End
[leave, Syntax.Document, null]
];
assert.deepEqual(resultOfDump, expected);
});
示例2: processor
processor(extension: string) {
processorArgs = { extension };
return {
preProcess(text: string, filePath: string) {
preProcessArgs = { text, filePath };
return parse(text);
},
postProcess(messages: TextlintMessage[], filePath: string) {
postProcessArgs = { messages, filePath };
return {
messages,
filePath: filePath || "unknown"
};
}
};
}