本文整理汇总了TypeScript中remarkable.render函数的典型用法代码示例。如果您正苦于以下问题:TypeScript render函数的具体用法?TypeScript render怎么用?TypeScript render使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: usage
usage() {
const md = new Remarkable();
md.render("# Remarkable rulezz!");
const importedMd = new ImportedRemarkable();
importedMd.render("# Remarkable rulezz!");
}
示例2: renderMd
export function renderMd(rawText:string, headersHandler?:HeadersHandler) {
let _origRule;
if (headersHandler) {
_origRule = {
open: md.renderer.rules.heading_open,
close: md.renderer.rules.heading_close
};
md.renderer.rules.heading_open = (tokens, idx) => {
if (tokens[idx].hLevel !== 1 ) {
return _origRule.open(tokens, idx);
} else {
return headersHandler.open(tokens, idx);
}
};
md.renderer.rules.heading_close = (tokens, idx) => {
if (tokens[idx].hLevel !== 1 ) {
return _origRule.close(tokens, idx);
} else {
return headersHandler.close(tokens, idx);
}
};
}
let res = md.render(rawText);
if (headersHandler) {
md.renderer.rules.heading_open = _origRule.open;
md.renderer.rules.heading_close = _origRule.close;
}
return res;
}
示例3: createMarkdownOutput
export async function createMarkdownOutput(
text: string,
template?: string,
): Promise<[ IPost | null, string, string ]> {
const parsed = /(?:^---\n)([\s\S]*)(?:---\n)(([\s\S])*)/gm.exec(text) || []
const hasFrontmatter = parsed.length
const md = (hasFrontmatter ? parsed[2] : text)
.replace(/\.jpeg/g, ".large.jpeg")
.replace(/\.jpg/g, ".large.jpg")
.replace(/\.png/g, ".large.png")
.replace(/\]\(\.\.\//g, "](../../")
const blog = remarkable.render(md)
if (!hasFrontmatter) {
const html = ejs.render(template || defaultTemplate, { blog, frontmatter: null })
return [ null, md, html ]
}
const frontmatter = load(parsed[1])
const html = ejs.render(template || defaultTemplate, { blog, frontmatter })
return [ frontmatter, md, html ]
}
示例4: Remarkable
return this.backendSrv.get(`/api/plugins/${this.pluginId}/markdown/readme`).then(res => {
var md = new Remarkable();
this.readmeHtml = this.$sce.trustAsHtml(md.render(res));
});
示例5: Remarkable
this.backendSrv.get(`/api/plugins/${this.datasourceInstance.meta.id}/markdown/query_help`).then(res => {
var md = new Remarkable();
this.helpHtml = this.$sce.trustAsHtml(md.render(res));
});
示例6: render
public render(raw: string):string {
return md.render(raw);
}