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