How to use the @ts-common/commonmark-to-markdown.parse function in @ts-common/commonmark-to-markdown

To help you get started, we’ve selected a few @ts-common/commonmark-to-markdown examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / oav / lib / validators / suppressions.ts View on Github external
export const getSuppressions = async (specPath: string): Promise => {
  // find readme.md
  try {
    const readMe = await amd.findReadMe(path.dirname(specPath))
    if (readMe === undefined) {
      return undefined
    }
    const readMeStr = await vfs.readFile(readMe)
    const cmd = md.parse(readMeStr)
    const suppressionCodeBlock = amd.getCodeBlocksAndHeadings(cmd.markDown).Suppression
    if (suppressionCodeBlock === undefined) {
      return undefined
    }
    const suppression = amd.getYamlFromNode(suppressionCodeBlock) as amd.Suppression
    if (!it.isArray(suppression.directive)) {
      return undefined
    }
    return suppression
  } catch (err) {
    log.warn(`Unable to load and parse suppression file. Error: ${err}`)
    return undefined
  }
}
github Azure / azure-rest-api-specs / scripts / latest-profile-generator.ts View on Github external
const main = async (specificationsDirectory: string, profilesDirectory: string) => {
  try {
    const list = fs.recursiveReaddir(specificationsDirectory);
    const specs = [];  
    let foundMultiApiReadmes = false;
    for await (const file of list) {
      const f = Path.parse(file);
      if (f.base === "readme.enable-multi-api.md") {
        foundMultiApiReadmes = true;
        const content = (await fs.readFile(file)).toString();
        const readMe = cm.parse(content);
        const set = new Set();
        for (const c of cm.iterate(readMe.markDown)) {
          if (
            c.type === "code_block" &&
            c.info !== null &&
            c.info.startsWith("yaml") &&
            c.literal !== null
          ) {
            const y = (yaml.load(c.literal) as Code)["input-file"];
            if (typeof y === "string") {
              set.add(y.replace('$(this-folder)', ''));
            } else if (it.isArray(y)) {
              for (const i of y) {
                let cleanFilePath = i.replace('$(this-folder)', '');
                set.add(cleanFilePath);
                specs.push(Path.join(f.dir, cleanFilePath));
github Azure / azure-rest-api-specs / scripts / multiapi.ts View on Github external
const main = async (dir: string) => {
  try {
    const list = fs.recursiveReaddir(dir)
    for await (const file of list) {
      const f = path.parse(file)
      if (f.base === "readme.md") {
        console.log(`processing ${file}`)
        const content = (await fs.readFile(file)).toString()
        const readMe = cm.parse(content)
        const set = new Set()
        for (const c of cm.iterate(readMe.markDown)) {
          if (
            c.type === "code_block" &&
            c.info !== null &&
            c.info.startsWith("yaml") &&
            c.literal !== null
          ) {
            const y = (yaml.load(c.literal) as Code)["input-file"]
            if (typeof y === "string") {
              set.add(y)
            } else if (it.isArray(y)) {
              for (const i of y) {
                set.add(i)
              }
            }

@ts-common/commonmark-to-markdown

Converts commonmark AST (back) to plain markdown

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Similar packages