本文整理匯總了TypeScript中markdown.markdown.parse方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript markdown.parse方法的具體用法?TypeScript markdown.parse怎麽用?TypeScript markdown.parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類markdown.markdown
的用法示例。
在下文中一共展示了markdown.parse方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: parse
public parse(mdText: string): void {
let version: string;
let changes: string[];
let author: string;
let date: string;
const tree: any = md.parse(mdText);
tree.forEach(function(elem: any, i: number, a: any): void {
if ((i === 0 && elem === "markdown")
|| (elem.length === 3 && elem[0] === "header" && elem[1].level !== undefined && elem[1].level === 1)) {
version = "";
}
else if (elem.length === 3 && elem[0] === "header" && elem[1].level !== undefined && elem[1].level === 2) {
version = elem[2];
}
else if (elem.length > 1 && elem[0] === "bulletlist") {
changes = [];
elem.forEach(function(e: any, i: number, a: any): void {
if (i !== 0 && (e.length !== 2 || e[0] !== "listitem")) {
throw new Error("Invalid changelog file format: " + e[0]);
}
else if (i !== 0) {
changes.push(e[1]);
}
});
}
else if (elem.length === 2 && elem[0] === "para" && elem[1].length === 2 && elem[1][0] === "em") {
const line: string[] = elem[1][1].split(", ");
if (line.length !== 2) {
throw new Error("Invalid changelog file format: " + elem[1][1]);
}
author = line[0];
date = line[1];
this._changes.push(new ChangeDescription(version, changes, author, date));
}
else if (elem.length !== 1 && elem[0] !== "hr") {
throw new Error("Invalid changelog file format: " + elem);
}
}, this);
}