-
Notifications
You must be signed in to change notification settings - Fork 9
/
options.js
96 lines (88 loc) · 1.95 KB
/
options.js
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const options = {
alwaysThrow: false,
compatibilityMode: false,
copyButtons: true,
correctnewlines: false,
markdownOptions: {
fences: true,
commonmark: true,
gfm: true,
ruleSpaces: false,
listItemIndent: '1',
spacedTable: true,
paddedTable: true,
},
lazyImages: true,
normalize: true,
safeMode: false,
settings: {
position: false,
},
theme: 'light',
};
/**
* @note disabling `newline`, `paragraph`, or `text` tokenizers trips Remark into an infinite loop!
*/
const blocks = [
// 'newline',
'indentedCode',
'fencedCode',
'blockquote',
'atxHeading',
'thematicBreak',
'list',
'setextHeading',
'html',
'footnote',
'definition',
'table',
// 'paragraph',
];
const inlines = [
'escape',
'autoLink',
'url',
'html',
'link',
'reference',
'strong',
'emphasis',
'deletion',
'code',
'break',
// 'text',
];
const toBeDecorated = {
inlines: inlines.filter(i => !['link', 'reference'].includes(i)),
blocks: [],
};
const disableTokenizers = {
inlines: {
disableTokenizers: {
inline: toBeDecorated.inlines,
block: toBeDecorated.blocks,
},
},
blocks: {
disableTokenizers: {
inline: inlines.filter(i => !toBeDecorated.inlines.includes(i)),
block: blocks.filter(b => !toBeDecorated.blocks.includes(b)),
},
},
};
const parseOptions = (userOpts = {}) => {
let opts = { ...options, ...userOpts };
if (opts.disableTokenizers in disableTokenizers) {
opts = { ...opts, ...disableTokenizers[opts.disableTokenizers] };
}
// @note: commenting out for now. While doing dev for @readme/editor, I would
// like fine-grained control of which tokenizers we are using. We might to
// remove that at some point?
// } else if (opts.disableTokenizers) {
// throw new Error(
// `opts.disableTokenizers "${opts.disableTokenizers}" not one of "${Object.keys(disableTokenizers)}"`
// );
// }
return opts;
};
export { options, parseOptions };