Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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>
function Parser(doc, file) {
this.file = file
this._parser = new OrgaParser()
}
return new Promise(resolve => {
const parser = new Parser()
const ast = parser.parse(node.internal.content)
resolve(ast)
})
}
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, i) => {
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>