summaryrefslogtreecommitdiff
path: root/util/uniorg.tsx
blob: e4d8dfd78bc67688b6b6bc4c1dbd3deb2075bdbe (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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