本文整理匯總了TypeScript中markdown.markdown.toHTMLTree方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript markdown.toHTMLTree方法的具體用法?TypeScript markdown.toHTMLTree怎麽用?TypeScript markdown.toHTMLTree使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類markdown.markdown
的用法示例。
在下文中一共展示了markdown.toHTMLTree方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: generate
generate () {
const self = this;
const tasks: ReturnType<typeof writeFileCreateDir>[] = [];
self.metadata.renderedFragments = {};
// For each markdown, create the html fragment
for (const mdTemplate in self.metadata.jsonml) {
try {
const tree = markdown.toHTMLTree(self.metadata.jsonml[mdTemplate]);
const html = markdown.renderJsonML(tree);
const outputFilename = self.generatorSettings.outputDir + '/' + mdTemplate + '.html';
// mhmhmh TODO: This is sooo hardcoded
self.metadata.renderedFragments[mdTemplate] = 'fragment/' + mdTemplate + '.html';
tasks.push(writeFileCreateDir(outputFilename, html));
} catch (e) {
// TODO: Catch this better
console.log(red('Problem with ') + mdTemplate);
throw e;
}
}
return Task.all(tasks);
}
示例2: renderMlBlock
export function renderMlBlock (jsonml: JSonML) {
try {
const tree = markdown.toHTMLTree(jsonml);
return markdown.renderJsonML(tree);
} catch (e) {
// TODO: Fix silent error
console.log(e);
return null;
}
}
示例3: Error
const getHtml = (metadata: Metadata) => (mdTemplate: string) => {
let tree;
if (!metadata.jsonml.hasOwnProperty(mdTemplate)) {
throw new Error('We Couldn\'t find a md template with the name ' + mdTemplate);
}
try {
tree = markdown.toHTMLTree(metadata.jsonml[mdTemplate]);
} catch (e) {
throw new Error('Couldnt create html for template ' + mdTemplate);
}
return markdown.renderJsonML(tree);
};