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