Skip to content

Commit cc8ec32

Browse files
committed
.
0 parents  commit cc8ec32

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3893
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
*.log
3+
.nyc_output/
4+
coverage/
5+
node_modules/
6+
yarn.lock
7+
mdast-util-to-markdown.min.js

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
coverage/
2+
*.json
3+
*.md

.remarkignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test/

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
language: node_js
2+
node_js:
3+
- lts/dubnium
4+
- node
5+
after_script: bash <(curl -s https://codecov.io/bash)

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./lib')

lib/handle/blockquote.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = blockquote
2+
3+
var flow = require('../util/container-flow')
4+
var indentLines = require('../util/indent-lines')
5+
6+
function blockquote(node, _, context) {
7+
var exit = context.enter('blockquote')
8+
var value = indentLines(flow(node, context), map)
9+
exit()
10+
return value
11+
}
12+
13+
function map(line, index, blank) {
14+
return (blank ? '>' : '> ') + line
15+
}

lib/handle/break.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = hardBreak
2+
hardBreak.peek = hardBreakPeek
3+
4+
function hardBreak() {
5+
return '\\\n'
6+
}
7+
8+
function hardBreakPeek() {
9+
return '\\'
10+
}

lib/handle/code.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
module.exports = code
2+
3+
var repeat = require('repeat-string')
4+
var streak = require('longest-streak')
5+
var indentLines = require('../util/indent-lines')
6+
var safe = require('../util/safe')
7+
var formatCodeAsIndented = require('../util/format-code-as-indented')
8+
9+
function code(node, _, context) {
10+
var marker = context.options.fence || '`'
11+
var raw = node.value || ''
12+
var suffix = marker === '`' ? 'GraveAccent' : 'Tilde'
13+
var value
14+
var fence
15+
var exit
16+
var exitInfo
17+
18+
if (formatCodeAsIndented(node, context)) {
19+
exit = context.enter('codeIndented')
20+
value = indentLines(raw, map)
21+
} else {
22+
fence = repeat(marker, Math.max(streak(raw, marker) + 1, 3))
23+
exit = context.enter('codeFenced')
24+
value = fence
25+
26+
if (node.lang) {
27+
exitInfo = context.enter('codeFencedLang' + suffix)
28+
value += safe(context, node.lang, {
29+
before: '`',
30+
after: ' ',
31+
encode: ['`']
32+
})
33+
exitInfo()
34+
}
35+
36+
if (node.lang && node.meta) {
37+
exitInfo = context.enter('codeFencedMeta' + suffix)
38+
value +=
39+
' ' +
40+
safe(context, node.meta, {
41+
before: ' ',
42+
after: '\n',
43+
encode: ['`']
44+
})
45+
exitInfo()
46+
}
47+
48+
value += '\n'
49+
50+
if (raw) {
51+
value += raw + '\n'
52+
}
53+
54+
value += fence
55+
}
56+
57+
exit()
58+
return value
59+
}
60+
61+
function map(line, _, blank) {
62+
return (blank ? '' : ' ') + line
63+
}

0 commit comments

Comments
 (0)