Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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`)
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 = {
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>
.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 }
.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}`
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)}/>