Skip to content
This repository was archived by the owner on Aug 9, 2023. It is now read-only.

Commit 0bb6e21

Browse files
committed
.
0 parents  commit 0bb6e21

File tree

12 files changed

+852
-0
lines changed

12 files changed

+852
-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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_Store
2+
*.log
3+
.nyc_output/
4+
coverage/
5+
node_modules/
6+
yarn.lock

.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

.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)

from-markdown.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
var normalizeIdentifier = require('micromark/dist/util/normalize-identifier')
2+
3+
exports.canContainEols = ['footnote']
4+
5+
exports.enter = {
6+
footnoteDefinition: enterFootnoteDefinition,
7+
footnoteDefinitionLabelString: enterFootnoteDefinitionLabelString,
8+
footnoteCall: enterFootnoteCall,
9+
footnoteCallString: enterFootnoteCallString,
10+
inlineNote: enterNote
11+
}
12+
exports.exit = {
13+
footnoteDefinition: exitFootnoteDefinition,
14+
footnoteDefinitionLabelString: exitFootnoteDefinitionLabelString,
15+
footnoteCall: exitFootnoteCall,
16+
footnoteCallString: exitFootnoteCallString,
17+
inlineNote: exitNote
18+
}
19+
20+
function enterFootnoteDefinition(token) {
21+
this.enter(
22+
{type: 'footnoteDefinition', identifier: '', label: '', children: []},
23+
token
24+
)
25+
}
26+
27+
function enterFootnoteDefinitionLabelString() {
28+
this.buffer()
29+
}
30+
31+
function exitFootnoteDefinitionLabelString(token) {
32+
var label = this.resume()
33+
this.stack[this.stack.length - 1].label = label
34+
this.stack[this.stack.length - 1].identifier = normalizeIdentifier(
35+
this.sliceSerialize(token)
36+
).toLowerCase()
37+
}
38+
39+
function exitFootnoteDefinition(token) {
40+
this.exit(token)
41+
}
42+
43+
function enterFootnoteCall(token) {
44+
this.enter({type: 'footnoteReference', identifier: '', label: ''}, token)
45+
}
46+
47+
function enterFootnoteCallString() {
48+
this.buffer()
49+
}
50+
51+
function exitFootnoteCallString(token) {
52+
var label = this.resume()
53+
this.stack[this.stack.length - 1].label = label
54+
this.stack[this.stack.length - 1].identifier = normalizeIdentifier(
55+
this.sliceSerialize(token)
56+
).toLowerCase()
57+
}
58+
59+
function exitFootnoteCall(token) {
60+
this.exit(token)
61+
}
62+
63+
function enterNote(token) {
64+
this.enter({type: 'footnote', children: []}, token)
65+
}
66+
67+
function exitNote(token) {
68+
this.exit(token)
69+
}

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
exports.fromMarkdown = require('./from-markdown')
2+
exports.toMarkdown = require('./to-markdown')

license

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(The MIT License)
2+
3+
Copyright (c) 2020 Titus Wormer <tituswormer@gmail.com>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
'Software'), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

package.json

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"name": "mdast-util-footnote",
3+
"version": "0.0.0",
4+
"description": "mdast extension to parse and serialize footnotes",
5+
"license": "MIT",
6+
"keywords": [
7+
"unist",
8+
"mdast",
9+
"mdast-util",
10+
"util",
11+
"utility",
12+
"markdown",
13+
"markup",
14+
"footnote",
15+
"note",
16+
"pandoc"
17+
],
18+
"repository": "syntax-tree/mdast-util-footnote",
19+
"bugs": "https://github.com/syntax-tree/mdast-util-footnote/issues",
20+
"funding": {
21+
"type": "opencollective",
22+
"url": "https://opencollective.com/unified"
23+
},
24+
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
25+
"contributors": [
26+
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
27+
],
28+
"files": [
29+
"from-markdown.js",
30+
"index.js",
31+
"to-markdown.js"
32+
],
33+
"dependencies": {
34+
"mdast-util-from-markdown": "^0.6.0",
35+
"micromark": "~2.8.0"
36+
},
37+
"devDependencies": {
38+
"mdast-util-to-markdown": "^0.3.0",
39+
"micromark-extension-footnote": "~0.2.0",
40+
"nyc": "^15.0.0",
41+
"prettier": "^2.0.0",
42+
"remark-cli": "^8.0.0",
43+
"remark-preset-wooorm": "^7.0.0",
44+
"tape": "^5.0.0",
45+
"xo": "^0.33.0"
46+
},
47+
"scripts": {
48+
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
49+
"test-api": "node test",
50+
"test-coverage": "nyc --reporter lcov tape test.js",
51+
"test": "npm run format && npm run test-coverage"
52+
},
53+
"nyc": {
54+
"check-coverage": true,
55+
"lines": 100,
56+
"functions": 100,
57+
"branches": 100
58+
},
59+
"prettier": {
60+
"tabWidth": 2,
61+
"useTabs": false,
62+
"singleQuote": true,
63+
"bracketSpacing": false,
64+
"semi": false,
65+
"trailingComma": "none"
66+
},
67+
"xo": {
68+
"prettier": true,
69+
"esnext": false
70+
},
71+
"remarkConfig": {
72+
"plugins": [
73+
"preset-wooorm"
74+
]
75+
}
76+
}

0 commit comments

Comments
 (0)