本文整理匯總了TypeScript中markdown-it.use函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript use函數的具體用法?TypeScript use怎麽用?TypeScript use使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了use函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: transform
transform(data: string): SafeHtml {
if (data) {
const md = new MarkdownIt();
md.use(markdownItAttrs);
return this.sanitizer.bypassSecurityTrustHtml(md.render(data));
} else {
return this.sanitizer.bypassSecurityTrustHtml('No Data');
}
}
示例2: initializeFullMarkdown
private initializeFullMarkdown(): MarkdownIt.MarkdownIt {
const mp: MarkdownIt.MarkdownIt =
new MarkdownIt("default", { linkify: true, typographer: true});
// tslint:disable-next-line
mp.renderer.rules["video"] = this.tokenize_video(mp);
mp.inline.ruler.before("emphasis", "video", this.video_embed(mp));
mp.use(MarkdownItLinks, {
target: "_blank",
rel: "noopener",
});
return mp;
}
示例3: require
import * as MarkdownIt from "markdown-it";
import MarkdownItContainer = require("markdown-it-container");
const md = new MarkdownIt();
md.use(MarkdownItContainer, 'spoiler', {
validate: (params: any) => params.trim().match(/^spoiler\s+(.*)$/),
render: (tokens: MarkdownIt.Token[], index: number) => {
const match = tokens[index].info.trim().match(/^spoiler\s+(.*)$/);
const onClick =
"this.parentNode.classList.toggle('_expanded');" +
"event.preventDefault();";
if (tokens[index].nesting === 1) {
return (
'<div class="markdown__spoiler">\n' +
'<div class="markdown__spoiler-title" onclick="' + onClick + '">\n' +
md.utils.escapeHtml(match && match[1] || '') + '\n' +
'</div>\n' +
'<div class="markdown__spoiler-content">\n'
);
} else {
return '</div></div>\n';
}
}
});
const src = `:::spoiler This Is Spoiler Title
Here is spoiler content.
:::`;
示例4: require
import * as MarkdownIt from "markdown-it";
import anchor = require("markdown-it-anchor");
const md = new MarkdownIt();
md.use(anchor, {
level: 1,
// slugify: string => string,
permalink: false,
// renderPermalink: (slug, opts, state, permalink) => {},
permalinkClass: 'header-anchor',
permalinkSymbol: 'Âś',
permalinkBefore: false
});
const src = `# First header
Lorem ipsum.
## Next section!
This is totaly awesome.`;
md.render(src);