Skip to content

Commit 7185a8b

Browse files
committed
Refactor code-style
1 parent 2cfb6a7 commit 7185a8b

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

index.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function enterMathFlowMeta() {
5050
}
5151

5252
function exitMathFlowMeta() {
53-
var data = this.resume()
53+
const data = this.resume()
5454
this.stack[this.stack.length - 1].meta = data
5555
}
5656

@@ -62,8 +62,8 @@ function exitMathFlowFence() {
6262
}
6363

6464
function exitMathFlow(token) {
65-
var data = this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, '')
66-
var node = this.exit(token)
65+
const data = this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, '')
66+
const node = this.exit(token)
6767
node.value = data
6868
node.data.hChildren[0].value = data
6969
this.setData('mathFlowInside')
@@ -86,8 +86,8 @@ function enterMathText(token) {
8686
}
8787

8888
function exitMathText(token) {
89-
var data = this.resume()
90-
var node = this.exit(token)
89+
const data = this.resume()
90+
const node = this.exit(token)
9191
node.value = data
9292
node.data.hChildren[0].value = data
9393
}
@@ -98,11 +98,11 @@ function exitMathData(token) {
9898
}
9999

100100
function math(node, _, context) {
101-
var raw = node.value || ''
102-
var fence = '$'.repeat(Math.max(longestStreak(raw, '$') + 1, 2))
103-
var exit = context.enter('mathFlow')
104-
var value = fence
105-
var subexit
101+
const raw = node.value || ''
102+
const fence = '$'.repeat(Math.max(longestStreak(raw, '$') + 1, 2))
103+
const exit = context.enter('mathFlow')
104+
let value = fence
105+
let subexit
106106

107107
if (node.meta) {
108108
subexit = context.enter('mathFlowMeta')
@@ -122,10 +122,9 @@ function math(node, _, context) {
122122
}
123123

124124
function inlineMath(node) {
125-
var value = node.value || ''
126-
var size = 1
127-
var pad = ''
128-
var sequence
125+
const value = node.value || ''
126+
let size = 1
127+
let pad = ''
129128

130129
// If there is a single dollar sign on its own in the math, use a fence of
131130
// two.
@@ -144,7 +143,7 @@ function inlineMath(node) {
144143
pad = ' '
145144
}
146145

147-
sequence = '$'.repeat(size)
146+
const sequence = '$'.repeat(size)
148147
return sequence + pad + value + pad + sequence
149148
}
150149

package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@
6161
"trailingComma": "none"
6262
},
6363
"xo": {
64-
"prettier": true,
65-
"rules": {
66-
"no-var": "off",
67-
"prefer-arrow-callback": "off"
68-
}
64+
"prettier": true
6965
},
7066
"remarkConfig": {
7167
"plugins": [

test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import toMarkdown from 'mdast-util-to-markdown'
44
import math from 'micromark-extension-math'
55
import {mathFromMarkdown, mathToMarkdown} from './index.js'
66

7-
test('markdown -> mdast', function (t) {
7+
test('markdown -> mdast', (t) => {
88
t.deepEqual(
99
fromMarkdown('a $b$ c', {
1010
extensions: [math],
@@ -137,7 +137,7 @@ test('markdown -> mdast', function (t) {
137137
t.end()
138138
})
139139

140-
test('mdast -> markdown', function (t) {
140+
test('mdast -> markdown', (t) => {
141141
t.deepEqual(
142142
toMarkdown(
143143
{type: 'inlineMath', value: 'a'},

0 commit comments

Comments
 (0)