aboutsummaryrefslogtreecommitdiff
path: root/tohtml.js
blob: b18c944050a82e4cc93dc324e24ec0694741859e (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const path = 'md';

const report = require('vfile-reporter');

/* TODO : Send the result of guide :
  const guide = require('remark-preset-lint-markdown-style-guide');
*/

const html = require('remark-rehype');
const kbd = require('remark-kbd');
const math = require('remark-math');
const highlight = require('remark-highlight.js');
const sb = require('remark-special-box');
const multiChoice = require('remark-multiple-choice');
const lineInput = require('remark-line-input');
const select = require('remark-select');
const textInput = require('remark-text-input');
const raw = require('rehype-raw');
const rehypeKatex = require('rehype-katex');
const rehypeStringify = require('rehype-stringify');
const unified = require('unified');
const remark = require('remark-parse');
const customBlocks = require('remark-custom-blocks');


function toHTML(data, fnc) {
  unified()
    .use(remark)
    .use(lineInput)
    .use(textInput)
    .use(select)
    .use(multiChoice)
    .use(math)
    .use(kbd)
    .use(sb)
    .use(customBlocks, {
      information: {
        classes: 'special-box information',
        title:   'optional'
      },
      comment: {
        classes: 'special-box comment',
        title:   'optional'
      },
      attention: {
        classes: 'special-box attention',
        title:   'optional'
      },
      question: {
        classes: 'special-box question',
        title:   'optional'
      },
      good: {
        classes: 'special-box good',
      },
      bad: {
        classes: 'special-box bad',
      }})
    .use(highlight)
    .use(html, {allowDangerousHTML: true})
    .use(rehypeKatex)
    .use(raw)
    .use(rehypeStringify)

    .process(data, fnc);
}

module.exports = toHTML;