当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript markdown-it.default函数代码示例

本文整理汇总了TypeScript中markdown-it.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了default函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: markdownIt

import url from "url";
import markdownIt from "markdown-it";
import mdUrl from "./markdown-url-to-html";

const markdown = markdownIt({
  html: true,
  linkify: true,
  typographer: true
}).use(transformLocalMdLinksToHTML);

function transformLocalMdLinksToHTML(md: any) {
  const defaultLinkOpenRender =
    md.renderer.rules.link_open ||
    function(tokens: any, idx: any, options: any, env: any, self: any) {
      return self.renderToken(tokens, idx, options);
    };
  md.renderer.rules.link_open = function(
    tokens: any,
    idx: any,
    options: any,
    env: any,
    self: any
  ) {
    const a = tokens[idx];
    const href = a.attrGet("href");
    if (href) {
      a.attrSet("href", localMarkdownLinkToHtmlLink(href));
    }
    return defaultLinkOpenRender(tokens, idx, options, env, self);
  };
}
开发者ID:joakin,项目名称:markdown-folder-to-html,代码行数:31,代码来源:markdown-to-html.ts

示例2: constructor

  constructor(options?: PluginOptions) {
    this._markdownProcessor = markdownIt(options);

    if (!!options && Array.isArray(options.plugins)) {
      options.plugins.map(this.installPlugin.bind(this));
    }
  }
开发者ID:webreed,项目名称:webreed-markdown-transformer,代码行数:7,代码来源:MarkdownTransformer.ts

示例3: pageModuleTemplate

module.exports = function bookLoader(content: string): string {
  this.cacheable(true);
  const query = loaderUtils.parseQuery(this.query);
  const {toc} = query;

  const {attributes, body} = fm<{[key: string]: any}>(content);

  if (query.markdown === false || attributes.markdown === false) {
    content = jsTemplate(body);
  } else {
    const {bookLoaderOptions = {}} = this;
    const md = markdownIt({
      html: true,
      ...bookLoaderOptions.markdownOptions,
    }).use(markdownJsTemplate);
    if (bookLoaderOptions.markdownPlugins) {
      bookLoaderOptions.markdownPlugins.forEach(md.use.bind(md));
    }
    content = md.render(body);
  }

  const context = query.context || this.options.context;

  const url = attributes.hasOwnProperty('url')
    ? attributes.url
    : loaderUtils.interpolateName(this, query.name || '[path][name].html', {
        context,
        content: content,
        regExp: query.regExp,
      });

  const template = attributes.hasOwnProperty('template')
    ? attributes.template
    : query.template;

  const emit = !![attributes.emit, query.emit, url].find(
    (o) => typeof o !== 'undefined',
  );

  return pageModuleTemplate({
    url,
    template,
    toc,
    attributes,
    emit,
    filename: path.relative(context, this.resourcePath),
    renderFunctionBody: content,
  });
};
开发者ID:also,项目名称:book-loader,代码行数:49,代码来源:index.ts

示例4: generateGravatar

declare const md5: any;
declare const saveAs: any;
declare const componentHandler: MDLHandler;

/**
 * Generate gravatar url from email
 */
export function generateGravatar(email: string) {
  return `https://gravatar.lug.ustc.edu.cn/avatar/${md5(email)}?d=404&r=g`;
}

const md = require("markdown-it");
const mdc = md({
  linkify: true,
  typographer: false,
  html: false,
  breaks: true,
});

mdc.renderer.rules.paragraph_open = (tokens: any[], idx: number, options: any, env: any, self: any) => {
  const token = tokens[idx];
  if(token.level === 0) return `<div class="mdl-card__supporting-text">`;
  else return self.renderToken(tokens, idx, options);
};

mdc.renderer.rules.paragraph_close = (tokens: any, idx: any, options: any, env: any, self: any) => {
  const token = tokens[idx];
  if(token.level === 0) return "</div>";
  else return self.renderToken(tokens, idx, options);
};
开发者ID:CircuitCoder,项目名称:ConsoleiT-Frontend,代码行数:30,代码来源:util.ts

示例5: createHtml

function createHtml(str, options = {}) {
  return cheerio.load(markdownIt(options).render(str));
}
开发者ID:also,项目名称:book-loader,代码行数:3,代码来源:outline.ts

示例6: createMd

function createMd(options?) {
  return markdownIt(options).use(markdownJsTemplate);
}
开发者ID:also,项目名称:book-loader,代码行数:3,代码来源:markdown-js-template.ts


注:本文中的markdown-it.default函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。