當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。