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


TypeScript markdown.markdown类代码示例

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


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

示例1: generate

    generate () {
        const self = this;
        const tasks: ReturnType<typeof writeFileCreateDir>[] = [];

        self.metadata.renderedFragments = {};

        // For each markdown, create the html fragment
        for (const mdTemplate in self.metadata.jsonml) {
            try {
                const tree = markdown.toHTMLTree(self.metadata.jsonml[mdTemplate]);
                const html = markdown.renderJsonML(tree);

                const outputFilename = self.generatorSettings.outputDir + '/' + mdTemplate + '.html';
                // mhmhmh TODO: This is sooo hardcoded
                self.metadata.renderedFragments[mdTemplate] = 'fragment/' + mdTemplate + '.html';

                tasks.push(writeFileCreateDir(outputFilename, html));

            } catch (e) {
                // TODO: Catch this better
                console.log(red('Problem with ') + mdTemplate);
                throw e;
            }
        }

        return Task.all(tasks);
    }
开发者ID:hrajchert,项目名称:mddoc,代码行数:27,代码来源:html-fragment-generator.ts

示例2: renderMlBlock

export function renderMlBlock (jsonml: JSonML) {
    try {
        const tree = markdown.toHTMLTree(jsonml);
        return markdown.renderJsonML(tree);
    } catch (e) {
        // TODO: Fix silent error
        console.log(e);
        return null;
    }
}
开发者ID:hrajchert,项目名称:mddoc,代码行数:10,代码来源:generator-helper-manager.ts

示例3: Error

const getHtml = (metadata: Metadata) => (mdTemplate: string) => {
    let tree;
    if (!metadata.jsonml.hasOwnProperty(mdTemplate)) {
        throw new Error('We Couldn\'t find a md template with the name ' + mdTemplate);
    }
    try {
        tree = markdown.toHTMLTree(metadata.jsonml[mdTemplate]);
    } catch (e) {
        throw new Error('Couldnt create html for template ' + mdTemplate);
    }

    return markdown.renderJsonML(tree);
};
开发者ID:hrajchert,项目名称:mddoc,代码行数:13,代码来源:generator-helper-manager.ts

示例4: parse

  public parse(mdText: string): void {
    let version: string;
    let changes: string[];
    let author: string;
    let date: string;
    const tree: any = md.parse(mdText);


    tree.forEach(function(elem: any, i: number, a: any): void {
      if ((i === 0 && elem === "markdown")
        || (elem.length === 3 && elem[0] === "header" && elem[1].level !== undefined && elem[1].level === 1)) {
        version = "";
      }
      else if (elem.length === 3 && elem[0] === "header" && elem[1].level !== undefined && elem[1].level === 2) {
        version = elem[2];
      }
      else if (elem.length > 1 && elem[0] === "bulletlist") {
        changes = [];
        elem.forEach(function(e: any, i: number, a: any): void {
          if (i !== 0 && (e.length !== 2 || e[0] !== "listitem")) {
            throw new Error("Invalid changelog file format: " + e[0]);
          }
          else if (i !== 0) {
            changes.push(e[1]);
          }
        });
      }
      else if (elem.length === 2 && elem[0] === "para" && elem[1].length === 2 && elem[1][0] === "em") {
        const line: string[] = elem[1][1].split(", ");
        if (line.length !== 2) {
          throw new Error("Invalid changelog file format: " + elem[1][1]);
        }
        author = line[0];
        date = line[1];
        this._changes.push(new ChangeDescription(version, changes, author, date));
      }
      else if (elem.length !== 1 && elem[0] !== "hr") {
        throw new Error("Invalid changelog file format: " + elem);
      }
    }, this);
  }
开发者ID:guedjm,项目名称:APIDocGenerator-pkg,代码行数:41,代码来源:changelog.ts


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