How to use orga - 9 common examples

To help you get started, we’ve selected a few orga 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 / on-node-create.ts View on Github external
if (d && d.end) { metadata.end = d.end }

          const absolutePath = `${orgFileNode.fileAbsolutePath}::*${title}`
          return {
            metadata,
            getAST: () => ast.parent, // we need the secion of the headline
            absolutePath,
          }
        })
    } else { // root
        const metadata = {
          export_file_name: orgFileNode.fileName,
          ...ast.meta }
      metadata.title = metadata.title || 'Untitled'
      const absolutePath = `${orgFileNode.fileAbsolutePath}`
      const d = parseTimestamp(metadata.date) ||
            parseTimestamp(metadata.export_date)
      if (d && d.date) { metadata.date = d.date }
      content = [ {
        metadata,
        getAST: () => ast,
        absolutePath,
      } ]
    }

    content.forEach((node, index) => {
      const id = `${orgFileNode.id} >>> OrgContent[${index}]`
      const ast = node.getAST()
      const contentDigest =
            crypto.createHash(`md5`)
                  .update(JSON.stringify(ast, getCircularReplacer()))
                  .digest(`hex`)
github orgapp / orgajs / packages / gatsby-transformer-orga / src / on-node-create.ts View on Github external
const absolutePath = `${orgFileNode.fileAbsolutePath}::*${title}`
          return {
            metadata,
            getAST: () => ast.parent, // we need the secion of the headline
            absolutePath,
          }
        })
    } else { // root
        const metadata = {
          export_file_name: orgFileNode.fileName,
          ...ast.meta }
      metadata.title = metadata.title || 'Untitled'
      const absolutePath = `${orgFileNode.fileAbsolutePath}`
      const d = parseTimestamp(metadata.date) ||
            parseTimestamp(metadata.export_date)
      if (d && d.date) { metadata.date = d.date }
      content = [ {
        metadata,
        getAST: () => ast,
        absolutePath,
      } ]
    }

    content.forEach((node, index) => {
      const id = `${orgFileNode.id} >>> OrgContent[${index}]`
      const ast = node.getAST()
      const contentDigest =
            crypto.createHash(`md5`)
                  .update(JSON.stringify(ast, getCircularReplacer()))
                  .digest(`hex`)
      const n = {
github orgapp / orgajs / www / src / pages / ast.jsx View on Github external
render() {
    const d = this.props.data.astToml
    const parser = new Parser()
    const replacer = (key, value) => {
      if ([`parent`].includes(key)) return
      if (Array.isArray(value) && value.length === 0) return
      return value
    }
    const examples = d.examples.map(e => {
      const obj = parser.parse(e.org)
      const json = JSON.stringify(obj.children[0], replacer, 2)
      console.log(json)
      return (
        <div>
          <h2>{ e.name }</h2>
          <p>{ e.desc }</p>
          <pre><code>{ e.org }</code></pre>
          <p>Yields:</p>
          <pre><code>{ json }</code></pre></div>
github orgapp / orgajs / packages / orga-unified / src / index.ts View on Github external
function Parser(doc, file) {
  this.file = file
  this._parser = new OrgaParser()
}
github orgapp / orgajs / packages / gatsby-transformer-orga / src / orga-util.ts View on Github external
return new Promise(resolve => {
    const parser = new Parser()
    const ast = parser.parse(node.internal.content)
    resolve(ast)
  })
}
github orgapp / orgajs / www / src / pages / ast.js View on Github external
render() {
    const d = this.props.data.astToml
    const parser = new Parser()
    const replacer = (key, value) =&gt; {
      if ([`parent`].includes(key)) return
      if (Array.isArray(value) &amp;&amp; value.length === 0) return
      return value
    }
    const examples = d.examples.map((e, i) =&gt; {
      const obj = parser.parse(e.org)
      const json = JSON.stringify(obj.children[0], replacer, 2)
      return (
        <div>
          <h2>{ e.name }</h2>
          <p>{ e.desc }</p>
          <pre><code>{ e.org }</code></pre>
          <p>Yields:</p>
          <pre><code>{ json }</code></pre>
        </div>
github orgapp / orgajs / packages / gatsby-transformer-orga / src / on-node-create.ts View on Github external
.map(ast => {
          const { date, export_date, export_title, ...properties } = getProperties(ast)
          const title = export_title || select(`text`, ast).value

          const d = parseTimestamp(date) ||
                parseTimestamp(export_date) ||
                select(`timestamp`, ast) ||
                select(`planning[keyword=CLOSED]`, ast)

          const metadata = {
            title,
            export_file_name: sanitise(title),
            category: category || orgFileNode.fileName,
            keyword: ast.keyword,
            tags: ast.tags,
            ...properties,
          }

          if (d && d.date) { metadata.date = d.date }
          if (d && d.end) { metadata.end = d.end }
github orgapp / orgajs / packages / gatsby-transformer-orga / src / on-node-create.ts View on Github external
.map(ast => {
          const { date, export_date, export_title, ...properties } = getProperties(ast)
          const title = export_title || select(`text`, ast).value

          const d = parseTimestamp(date) ||
                parseTimestamp(export_date) ||
                select(`timestamp`, ast) ||
                select(`planning[keyword=CLOSED]`, ast)

          const metadata = {
            title,
            export_file_name: sanitise(title),
            category: category || orgFileNode.fileName,
            keyword: ast.keyword,
            tags: ast.tags,
            ...properties,
          }

          if (d && d.date) { metadata.date = d.date }
          if (d && d.end) { metadata.end = d.end }

          const absolutePath = `${orgFileNode.fileAbsolutePath}::*${title}`
github orgapp / orgajs / www / src / pages / index.js View on Github external
export default () =&gt; {
  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;
        
        
          
        

orga

org-mode parser

MIT
Latest version published 12 months ago

Package Health Score

61 / 100
Full package analysis

Similar packages