Skip to content

Commit 17e0035

Browse files
committed
.
0 parents  commit 17e0035

12 files changed

+732
-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: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
'use strict'
2+
3+
exports.enter = {
4+
mathFlow: enterMathFlow,
5+
mathFlowFenceMeta: enterMathFlowMeta,
6+
mathText: enterMathText
7+
}
8+
exports.exit = {
9+
mathFlow: exitMathFlow,
10+
mathFlowFence: exitMathFlowFence,
11+
mathFlowFenceMeta: exitMathFlowMeta,
12+
mathFlowValue: exitMathData,
13+
mathText: exitMathText,
14+
mathTextData: exitMathData
15+
}
16+
17+
function enterMathFlow(token) {
18+
this.enter(
19+
{
20+
type: 'math',
21+
meta: null,
22+
value: '',
23+
data: {
24+
hName: 'div',
25+
hProperties: {className: ['math', 'math-display']},
26+
hChildren: [{type: 'text', value: ''}]
27+
}
28+
},
29+
token
30+
)
31+
}
32+
33+
function enterMathFlowMeta() {
34+
this.buffer()
35+
}
36+
37+
function exitMathFlowMeta() {
38+
var data = this.resume()
39+
this.stack[this.stack.length - 1].meta = data
40+
}
41+
42+
function exitMathFlowFence() {
43+
// Exit if this is the closing fence.
44+
if (this.getData('mathFlowInside')) return
45+
this.buffer()
46+
this.setData('mathFlowInside', true)
47+
}
48+
49+
function exitMathFlow(token) {
50+
var data = this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, '')
51+
var node = this.exit(token)
52+
node.value = data
53+
node.data.hChildren[0].value = data
54+
this.setData('mathFlowInside')
55+
}
56+
57+
function enterMathText(token) {
58+
this.enter(
59+
{
60+
type: 'inlineMath',
61+
value: '',
62+
data: {
63+
hName: 'span',
64+
hProperties: {className: ['math', 'math-inline']},
65+
hChildren: [{type: 'text', value: ''}]
66+
}
67+
},
68+
token
69+
)
70+
this.buffer()
71+
}
72+
73+
function exitMathText(token) {
74+
var data = this.resume()
75+
var node = this.exit(token)
76+
node.value = data
77+
node.data.hChildren[0].value = data
78+
}
79+
80+
function exitMathData(token) {
81+
this.config.enter.data.call(this, token)
82+
this.config.exit.data.call(this, token)
83+
}

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

0 commit comments

Comments
 (0)