Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
highlight: (code, lang) => {
try {
const nodes = highlight(code, lang);
return rehype()
.stringify({ type: 'root', children: nodes })
.toString();
} catch (err) {
if (/Unknown language/.test(err.message)) {
return escape(code);
}
throw err;
}
},
});
export default ({ children, className }) => (
<pre> {className ? (
<code>
) : (
<code>{children}</code>
)}
<style>
{`
pre {
background-color: var(--lighter-gray);
color: var(--fg);</style></code></pre>
function toPlainTree(domString) {
return rehype()
.use(removeSlateArtifacts)
.data('settings', { fragment: true })
.processSync(domString).contents;
}
import remarkHtml from 'remark-html'
import remark from 'remark'
import rehypePrism from '@mapbox/rehype-prism'
import rehypeSlug from 'rehype-slug'
import rehype from 'rehype'
const htmlRehype = rehype()
.use(rehypeSlug)
.use(rehypePrism, { ignoreMissing: true, preLangClass: false })
export default async data => {
const { contents: html } = await remark()
.use(remarkHtml)
.process(data)
return htmlRehype.process(html)
}
export default function Code({
className,
children,
language,
style,
}) {
const nodes = refractor.highlight(children, language);
const html = rehype()
.stringify({ type: 'root', children: nodes })
.toString();
return (
<pre style="{style}"> );
}
</pre>
export const getHighlightedHTML = (code: string, lang: string): string => {
const ast = getHast(code, lang);
if (ast) {
return rehype()
.stringify({ type: "root", children: ast })
.toString();
}
return code;
};
'use strict'
var start = require('unified-args')
var processor = require('rehype')
var proc = require('rehype/package.json')
var cli = require('./package.json')
start({
processor: processor,
name: proc.name,
description: cli.description,
version: [
proc.name + ': ' + proc.version,
cli.name + ': ' + cli.version
].join(', '),
pluginPrefix: proc.name,
packageField: proc.name,
rcName: '.' + proc.name + 'rc',
ignoreName: '.' + proc.name + 'ignore',
extensions: ['html', 'htm', 'xht', 'xhtml']
})
#!/usr/bin/env node
'use strict'
var start = require('unified-args')
var processor = require('rehype')
var proc = require('rehype/package.json')
var cli = require('./package.json')
start({
processor: processor,
name: proc.name,
description: cli.description,
version: [
proc.name + ': ' + proc.version,
cli.name + ': ' + cli.version
].join(', '),
pluginPrefix: proc.name,
packageField: proc.name,
rcName: '.' + proc.name + 'rc',
ignoreName: '.' + proc.name + 'ignore',
extensions: ['html', 'htm', 'xht', 'xhtml']
})