diff options
author | Thomas F. K. Jorna <[email protected]> | 2021-09-27 13:36:58 +0200 |
---|---|---|
committer | Thomas F. K. Jorna <[email protected]> | 2021-09-27 13:36:58 +0200 |
commit | ec6f3e51bb7f33594c7d0151fc3bf1f09db4115a (patch) | |
tree | af8925f3a75c6b5454ac5005a4263c2446e0d351 /util/uniorg.tsx | |
parent | cb29db132f79f9d35b323ae12524137cf5985018 (diff) |
feat: get org text from emacs
Diffstat (limited to 'util/uniorg.tsx')
-rw-r--r-- | util/uniorg.tsx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/util/uniorg.tsx b/util/uniorg.tsx new file mode 100644 index 0000000..e4d8dfd --- /dev/null +++ b/util/uniorg.tsx @@ -0,0 +1,25 @@ +import unified from 'unified' +import createStream from 'unified-stream' +import uniorgParse from 'uniorg-parse' +import uniorg2rehype from 'uniorg-rehype' +import highlight from 'rehype-highlight' +import katex from 'rehype-katex' +import rehype2react from 'rehype-react' +import React from 'react' + +export interface uniorgProps { + orgText: string +} + +const uniorg = (props: uniorgProps) => { + const { orgText } = props + const processor = unified() + .use(uniorgParse) + .use(uniorg2rehype) + .use(katex) + .use(rehype2react, { createElement: React.createElement }) + + return processor.processSync(orgText) +} + +export default uniorg |