From ec6f3e51bb7f33594c7d0151fc3bf1f09db4115a Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Mon, 27 Sep 2021 13:36:58 +0200 Subject: feat: get org text from emacs --- util/getOrgText.ts | 0 util/uniorg.tsx | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 util/getOrgText.ts create mode 100644 util/uniorg.tsx (limited to 'util') diff --git a/util/getOrgText.ts b/util/getOrgText.ts new file mode 100644 index 0000000..e69de29 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 -- cgit v1.2.3