当前位置: 首页>>代码示例>>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;未经允许,请勿转载。