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


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

本文整理匯總了TypeScript中markdown-it.render函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript render函數的具體用法?TypeScript render怎麽用?TypeScript render使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了render函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: authToken

router.post("/add_announce", async ctx => {
  await authToken(ctx, true);
  const { title, content } = ctx.request.body;
  if (!title) {
    return raiseApiError(400, "未填寫通知標題");
  }
  const announce = new Announce(title, md.render(content));
  await getRepository(Announce).save(announce);
  await announceMail(announce, await getRepository(User).find());
  ctx.body = { message: "創建成功" };
});
開發者ID:coderfox,項目名稱:Another-SS-Panel,代碼行數:11,代碼來源:api.ts

示例3: Announce

router.post("/announces", async ctx => {
  const announce = new Announce(
    ctx.request.body.title,
    md.render(ctx.request.body.content)
  );
  await connection.getRepository(Announce).save(announce);
  const users = await connection.getRepository(User).find();
  // TODO: use job queues
  await announceMail(announce, users);
  // TODO: better appearance
  ctx.response.status = 200;
  ctx.response.type = "text/html";
  ctx.response.body = `Succeeded.<a href="/admin">Go back</a>`;
});
開發者ID:coderfox,項目名稱:Another-SS-Panel,代碼行數:14,代碼來源:admin.ts

示例4: parsePageMetadata

/**
 * Parse the AST of a file and get metadata about it
 */
function parsePageMetadata(filePath: string, sourceContent: string): PageMetadata {
  const markup = md.render(sourceContent).replace(/\n/g, '');
  const fileName = path.basename(filePath, '.md');
  return {
    id: fileName,
    name: convertToCamelCase(fileName),
    title: convertToSentence(fileName),
    section: path
      .dirname(filePath)
      .split('/') // Platform specific File separator doesn't apply
      .slice(-2, -1)[0],
    template: markup,
    route: path
      .dirname(filePath)
      .split('/')
      .slice(3)
      .join('/'),
  };
}
開發者ID:bullhorn,項目名稱:novo-elements,代碼行數:22,代碼來源:examples-routes.ts

示例5: process

function process(
  markdown_string: string,
  mode: "default" | "frontmatter"
): MD2html {
  let text: string;
  let math: string[];
  // console.log(0, JSON.stringify(markdown_string));
  // console.log(1, JSON.stringify(math_escape(markdown_string)));
  [text, math] = remove_math(math_escape(markdown_string));
  // console.log(2, JSON.stringify(text), JSON.stringify(math));
  // Process checkboxes [ ].
  text = checkboxes(text);

  let html: string;
  let frontmatter = "";

  // avoid instantiating a new markdown object for normal md processing
  if (mode == "frontmatter") {
    const md_frontmatter = new MarkdownIt(OPTIONS).use(
      MarkdownItFrontMatter,
      fm => {
        frontmatter = fm;
      }
    );
    html = md_frontmatter.render(text);
  } else {
    html = markdown_it.render(text);
  }

  // console.log(3, JSON.stringify(html));
  // Substitute processed math back in.
  html = replace_math(html, math);
  // console.log(4, JSON.stringify(html));
  html = math_unescape(html);
  // console.log(5, JSON.stringify(html));
  return { html, frontmatter };
}
開發者ID:DrXyzzy,項目名稱:smc,代碼行數:37,代碼來源:markdown.ts

示例6: MarkdownIt

import * as MarkdownIt from "markdown-it";

{
    const md = new MarkdownIt();
    var result = md.render('# markdown-it rulezz!');
}

{
    var md = MarkdownIt();
    var result = md.render('# markdown-it rulezz!');
    var result = md.renderInline('__markdown-it__ rulezz!');
}

{
    var md = MarkdownIt('commonmark');
}

{
    var md = MarkdownIt({
        html: true,
        linkify: true,
        typographer: true
    });
}

{
    var md = MarkdownIt({
        html: false,
        xhtmlOut: false,
        breaks: false,
        langPrefix: 'language-',
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:markdown-it-tests.ts

示例7: MarkdownIt

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.
:::`;

md.render(src);
開發者ID:Crevil,項目名稱:DefinitelyTyped,代碼行數:29,代碼來源:markdown-it-container-tests.ts

示例8: MarkdownItRenderer

function MarkdownItRenderer(input: any) {
  return rnd.render(DOMPurify.sanitize(input, { ALLOWED_TAGS: [] }))
}
開發者ID:nehbit,項目名稱:aether-public,代碼行數:3,代碼來源:markdown.ts


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