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