Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
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
function transformer(node, file, next) {
destination.run(toHAST(node, options), file, done);
function done(err) {
next(err);
}
}
}
function transformer(node) {
return toHAST(node, options);
}
}
function transformer(node, file, next) {
destination.run(toHAST(node, options), file, done);
function done(err) {
next(err);
}
}
}
function transformer(node) {
return toHAST(node, options);
}
}
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)}/>
<h1>OAST</h1>