本文整理汇总了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);
};