當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript markdown-it.use函數代碼示例

本文整理匯總了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');
   }
 }
開發者ID:daniru,項目名稱:blog,代碼行數:9,代碼來源:markdown.pipe.ts

示例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;
 }
開發者ID:extendedmind,項目名稱:extendedmind,代碼行數:12,代碼來源:rendering.ts

示例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.
:::`;
開發者ID:Crevil,項目名稱:DefinitelyTyped,代碼行數:30,代碼來源:markdown-it-container-tests.ts

示例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);
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:21,代碼來源:markdown-it-anchor-tests.ts


注:本文中的markdown-it.use函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。