How to use oast-to-hast - 6 common examples

To help you get started, we’ve selected a few oast-to-hast 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 orgapp / orgajs / packages / gatsby-transformer-orga / src / extend-node-type.ts View on Github external
}
    const filesToCopy = new Map()
    const highlight = pluginOptions.noHighlight !== true
    const handlers = { link: handleLink }

    // offset the levels
    const firstHeadline = select('headline', body)
    const offset = firstHeadline ? firstHeadline.level - 1 : 0
    if (offset > 0) {
      body = map(body, node => {
        if (node.type !== `headline`) return node
        return { ...node, level: node.level - offset }
      })
    }

    const hast = toHAST(body, { highlight, handlers })
    const html = hastToHTML(hast, { allowDangerousHTML: true })
    await Promise.all(Array.from(filesToCopy, async ([linkPath, newFilePath]) => {
      // Don't copy anything is the file already exists at the location.
      if (!fsExtra.existsSync(newFilePath)) {
        try {
          await fsExtra.ensureDir(dirname(newFilePath))
          await fsExtra.copy(linkPath, newFilePath)
        } catch (err) {
          console.error(`error copying file`, err)
        }
      }
    }))
    return html

    function handleLink(h, node) {
      const { uri, desc } = node
github orgapp / orgajs / packages / orga-rehype / src / index.ts View on Github external
function transformer(node, file, next) {
    destination.run(toHAST(node, options), file, done);
    function done(err) {
      next(err);
    }
  }
}
github orgapp / orgajs / packages / orga-rehype / src / index.ts View on Github external
function transformer(node) {
    return toHAST(node, options);
  }
}
github orgapp / orgajs / packages / orga-rehype / lib / index.js View on Github external
function transformer(node, file, next) {
    destination.run(toHAST(node, options), file, done);
    function done(err) {
      next(err);
    }
  }
}
github orgapp / orgajs / packages / orga-rehype / lib / index.js View on Github external
function transformer(node) {
    return toHAST(node, options);
  }
}
github orgapp / orgajs / www / src / pages / index.js View on Github external
export default () => {
  const [text, setText] = useState('')
  const oast = parse(text)
  const hast = toHAST(oast)
  const html = stringify(hast)

  return (
    
      
        
          <input value="{text}" rows="10"> setText(e.target.value)}/&gt;
        
        
          
        
      
      <h1>OAST</h1>

oast-to-hast

Transform OAST to HAST

MIT
Latest version published 12 months ago

Package Health Score

61 / 100
Full package analysis

Popular oast-to-hast functions