-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathharness.js
119 lines (90 loc) · 2.33 KB
/
harness.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
var unified = require('unified')
var markdown = require('remark-parse')
var remark2rehype = require('remark-rehype')
var format = require('rehype-format')
var html = require('rehype-stringify')
var report = require('vfile-reporter')
var tokenizeWords = require('space-separated-tokens')
var containers = require('./src/index')
var processor = unified()
.use(markdown)
.use(containers, {
default: true,
custom: [{
type: 'sidebar',
element: 'aside',
transform: function (node, config, tokenize) {
node.data.hProperties = {
className: config || 'left'
}
}
}, {
type: 'callout',
element: 'article',
transform: function (node, config, tokenize) {
node.data.hProperties = {
className: config || 'left'
}
}
}, {
type: 'quote',
element: 'aside',
transform: function (node, config, tokenize) {
var words = tokenizeWords.parse(config)
node.data.hProperties = {
className: `quoted ${words.shift()}`
}
node.children.push({
type: 'footer',
data: {
hName: 'footer'
},
children: tokenize(words.join(' '))
})
}
}]
})
.use(remark2rehype)
// .use(format)
.use(html, {})
const fs = require('fs')
// const text = `
// ::: div drop-caps-list
// ::: div drop-cap 1
// **Choose a crew type.** The crew type determines the group’s purpose, their special abilities, and how they advance.
// You begin at **Tier 0**, with **strong hold** and 0 {rep}. You start with 2 {coin}.
// :::
// :::
// What if we have a paragraph between these containers?
// ::: div columns
// ## Header of my other div
// and some content to mak us all happy
// :::
// `
// const text = `
// ::: div outer
// # Header One
// Outer contents.
// ::: quote quote attribution
// - not
// - to be
// - parsed
// :::
// More outer contents.
// :::
// `
let text = `
::: noparse div outer
# Header One
Outer contents.
::: div inner
Inner contents.
:::
More outer contents.
:::
`
console.log(text)
processor.process(text, function (err, file) {
console.error(report(err || file))
console.log(file.toString())
})