Skip to content

Commit 8e31dbf

Browse files
committed
Use let and const instead of var
1 parent dc10afb commit 8e31dbf

File tree

8 files changed

+168
-169
lines changed

8 files changed

+168
-169
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ site:
2626
rm -rf _site/ && mkdir -p _site/examples/
2727
git -C _site/ clone -b v4.0.12 --depth 1 https://github.com/markedjs/marked.git
2828
git -C _site/ clone -b 3.2.0 --depth 1 https://github.com/mathjax/mathjax.git
29-
rm -rf _site/markedjs/.git/
29+
rm -rf _site/marked/.git/
3030
rm -rf _site/mathjax/.git/
3131
# Create examples directory.
3232
sed -e 's|https:.*marked.min.js|../marked/marked.min.js|' \

test/test-main.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
var assert = require('assert')
2-
var url = require('url')
3-
var path = require('path')
4-
var jsdom = require('jsdom')
5-
var marked = require('marked')
6-
var texme = require('../texme.js')
1+
const assert = require('assert')
2+
const url = require('url')
3+
const path = require('path')
4+
const jsdom = require('jsdom')
5+
const marked = require('marked')
6+
const texme = require('../texme.js')
77

88
describe('main', function () {
99
afterEach(function () {
@@ -14,7 +14,7 @@ describe('main', function () {
1414
})
1515

1616
it('texme definition in browser', function () {
17-
var html = '<!DOCTYPE html><textarea>Foo'
17+
const html = '<!DOCTYPE html><textarea>Foo'
1818
global.window = new jsdom.JSDOM(html).window
1919
global.window.marked = marked
2020
global.window.texme = {
@@ -29,8 +29,8 @@ describe('main', function () {
2929
})
3030

3131
it('marked definition in browser', function (done) {
32-
var html = '<!DOCTYPE html><textarea>Foo'
33-
var options = {
32+
const html = '<!DOCTYPE html><textarea>Foo'
33+
const options = {
3434
url: new url.URL(path.join('file:///', __filename)),
3535
runScripts: 'dangerously',
3636
resources: 'usable'
@@ -49,7 +49,7 @@ describe('main', function () {
4949
})
5050

5151
it('render on load enabled', function (done) {
52-
var html = '<!DOCTYPE html><textarea>Foo'
52+
const html = '<!DOCTYPE html><textarea>Foo'
5353
global.window = new jsdom.JSDOM(html).window
5454
global.window.marked = marked
5555

@@ -65,7 +65,7 @@ describe('main', function () {
6565
})
6666

6767
it('render on load disabled', function (done) {
68-
var html = '<!DOCTYPE html><textarea>Foo'
68+
const html = '<!DOCTYPE html><textarea>Foo'
6969
global.window = new jsdom.JSDOM(html).window
7070
global.window.marked = marked
7171

test/test-mask.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
var assert = require('assert')
2-
var texme = require('../texme.js')
1+
const assert = require('assert')
2+
const texme = require('../texme.js')
33

4-
var MARK = texme.tokenType.MARK
5-
var MASK = texme.tokenType.MASK
6-
var MASK_LITERAL = texme.tokenLiteral.MASK
4+
const MARK = texme.tokenType.MARK
5+
const MASK = texme.tokenType.MASK
6+
const MASK_LITERAL = texme.tokenLiteral.MASK
77

88
describe('mask', function () {
99
it('markdown', function () {
10-
var tokens = [[MARK, 'Foo']]
11-
var expected = { text: 'Foo', tokenValues: [] }
10+
const tokens = [[MARK, 'Foo']]
11+
const expected = { text: 'Foo', tokenValues: [] }
1212
assert.deepStrictEqual(texme.mask(tokens), expected)
1313
})
1414

1515
it('math', function () {
16-
var input = '$ 1 + 1 = 2 $'
17-
var tokens = [[MASK, input]]
18-
var expected = { text: MASK_LITERAL, tokenValues: [input] }
16+
const input = '$ 1 + 1 = 2 $'
17+
const tokens = [[MASK, input]]
18+
const expected = { text: MASK_LITERAL, tokenValues: [input] }
1919
assert.deepStrictEqual(texme.mask(tokens), expected)
2020
})
2121

2222
it('mask literal', function () {
23-
var input = MASK_LITERAL
24-
var tokens = [[MASK, input]]
25-
var expected = { text: MASK_LITERAL, tokenValues: [input] }
23+
const input = MASK_LITERAL
24+
const tokens = [[MASK, input]]
25+
const expected = { text: MASK_LITERAL, tokenValues: [input] }
2626
assert.deepStrictEqual(texme.mask(tokens), expected)
2727
})
2828

2929
it('mixed', function () {
30-
var tokens = [
30+
const tokens = [
3131
[MARK, 'Foo'],
3232
[MASK, '$ 1 $'],
3333
[MASK, MASK_LITERAL],
3434
[MARK, 'Bar']]
3535

36-
var expected = {
36+
const expected = {
3737
text: 'Foo' + MASK_LITERAL + MASK_LITERAL + 'Bar',
3838
tokenValues: ['$ 1 $', MASK_LITERAL]
3939
}

test/test-render-markdown.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var assert = require('assert')
2-
var texme = require('../texme.js')
1+
const assert = require('assert')
2+
const texme = require('../texme.js')
33

44
describe('renderMarkdown', function () {
55
before(function () {
@@ -8,8 +8,8 @@ describe('renderMarkdown', function () {
88
})
99

1010
it('simple', function () {
11-
var input = '*Foo* **Bar** `Baz`'
12-
var expected = '<p><em>Foo</em> <strong>Bar</strong> <code>Baz</code></p>\n'
11+
const input = '*Foo* **Bar** `Baz`'
12+
const expected = '<p><em>Foo</em> <strong>Bar</strong> <code>Baz</code></p>\n'
1313
assert.deepStrictEqual(texme.renderMarkdown(input), expected)
1414
})
1515
})

test/test-render-page.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
var assert = require('assert')
2-
var jsdom = require('jsdom')
3-
var sinon = require('sinon')
4-
var texme = require('../texme.js')
1+
const assert = require('assert')
2+
const jsdom = require('jsdom')
3+
const sinon = require('sinon')
4+
const texme = require('../texme.js')
55

66
describe('renderPage', function () {
77
before(function () {
@@ -10,7 +10,7 @@ describe('renderPage', function () {
1010
})
1111

1212
it('content in textarea', function () {
13-
var html = '<textarea>Foo'
13+
const html = '<textarea>Foo'
1414

1515
global.window = new jsdom.JSDOM(html).window
1616
global.window.MathJax = { typeset: sinon.fake() }
@@ -23,7 +23,7 @@ describe('renderPage', function () {
2323
})
2424

2525
it('content in body', function () {
26-
var html = 'Foo'
26+
const html = 'Foo'
2727

2828
global.window = new jsdom.JSDOM(html).window
2929
global.window.MathJax = { typeset: sinon.fake() }
@@ -36,8 +36,8 @@ describe('renderPage', function () {
3636
})
3737

3838
it('mathjax typeset', function () {
39-
var html = '<!DOCTYPE html><textarea>Foo'
40-
var fakeTypesetFunction = sinon.fake()
39+
const html = '<!DOCTYPE html><textarea>Foo'
40+
const fakeTypesetFunction = sinon.fake()
4141

4242
global.window = new jsdom.JSDOM(html).window
4343
global.window.MathJax = { typeset: fakeTypesetFunction }
@@ -49,7 +49,7 @@ describe('renderPage', function () {
4949
})
5050

5151
it('implicit title from content', function () {
52-
var html = '<!DOCTYPE html><textarea>Foo\nBar\nBaz'
52+
const html = '<!DOCTYPE html><textarea>Foo\nBar\nBaz'
5353

5454
global.window = new jsdom.JSDOM(html).window
5555
global.window.MathJax = { typeset: sinon.fake() }
@@ -61,7 +61,7 @@ describe('renderPage', function () {
6161
})
6262

6363
it('remove leading and trailing spaces in implicit title', function () {
64-
var html = '<!DOCTYPE html><textarea> \n \tFoo\t \nBar\nBaz'
64+
const html = '<!DOCTYPE html><textarea> \n \tFoo\t \nBar\nBaz'
6565

6666
global.window = new jsdom.JSDOM(html).window
6767
global.window.MathJax = { typeset: sinon.fake() }
@@ -73,7 +73,7 @@ describe('renderPage', function () {
7373
})
7474

7575
it('remove leading and trailing hashes in implicit title', function () {
76-
var html = '<!DOCTYPE html><textarea>### Foo ###\nBar\nBaz'
76+
const html = '<!DOCTYPE html><textarea>### Foo ###\nBar\nBaz'
7777

7878
global.window = new jsdom.JSDOM(html).window
7979
global.window.MathJax = { typeset: sinon.fake() }
@@ -85,7 +85,7 @@ describe('renderPage', function () {
8585
})
8686

8787
it('explicit title intact', function () {
88-
var html = '<!DOCTYPE html><title>Qux</title><textarea>Foo\nBar\nBaz'
88+
const html = '<!DOCTYPE html><title>Qux</title><textarea>Foo\nBar\nBaz'
8989

9090
global.window = new jsdom.JSDOM(html).window
9191
global.window.MathJax = { typeset: sinon.fake() }
@@ -97,7 +97,7 @@ describe('renderPage', function () {
9797
})
9898

9999
it('spaces and hashes intact in explicit title', function () {
100-
var html = '<!DOCTYPE html><title>### Qux ###</title><textarea>Foo'
100+
const html = '<!DOCTYPE html><title>### Qux ###</title><textarea>Foo'
101101

102102
global.window = new jsdom.JSDOM(html).window
103103
global.window.MathJax = { typeset: sinon.fake() }
@@ -109,7 +109,7 @@ describe('renderPage', function () {
109109
})
110110

111111
it('explicit title intact', function () {
112-
var html = '<!DOCTYPE html><title>Qux</title><textarea>Foo\nBar\nBaz'
112+
const html = '<!DOCTYPE html><title>Qux</title><textarea>Foo\nBar\nBaz'
113113

114114
global.window = new jsdom.JSDOM(html).window
115115
global.window.MathJax = { typeset: sinon.fake() }

test/test-render.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
var assert = require('assert')
2-
var texme = require('../texme.js')
1+
const assert = require('assert')
2+
const texme = require('../texme.js')
33

4-
var MASK_LITERAL = texme.tokenLiteral.MASK
4+
const MASK_LITERAL = texme.tokenLiteral.MASK
55

66
describe('render', function () {
77
before(function () {
@@ -10,48 +10,48 @@ describe('render', function () {
1010
})
1111

1212
it('markdown', function () {
13-
var input = '*Foo* **Bar** `Baz`'
14-
var expected = '<p><em>Foo</em> <strong>Bar</strong> <code>Baz</code></p>\n'
13+
const input = '*Foo* **Bar** `Baz`'
14+
const expected = '<p><em>Foo</em> <strong>Bar</strong> <code>Baz</code></p>\n'
1515
assert.deepStrictEqual(texme.render(input), expected)
1616
})
1717

1818
it('math', function () {
19-
var input = '$ 1 + 1 = 2 $'
20-
var expected = '<p>$ 1 + 1 = 2 $</p>\n'
19+
const input = '$ 1 + 1 = 2 $'
20+
const expected = '<p>$ 1 + 1 = 2 $</p>\n'
2121
assert.deepStrictEqual(texme.render(input), expected)
2222
})
2323

2424
it('mask literal', function () {
25-
var input = MASK_LITERAL
26-
var expected = '<p>' + MASK_LITERAL + '</p>\n'
25+
const input = MASK_LITERAL
26+
const expected = '<p>' + MASK_LITERAL + '</p>\n'
2727
assert.deepStrictEqual(texme.render(input), expected)
2828
})
2929

3030
it('mixed', function () {
31-
var input = '*Foo* $ 1 + 1 = 2 $ **Bar** $$ 2 + 2 = 4 $$'
32-
var expected = '<p><em>Foo</em> $ 1 + 1 = 2 $ <strong>Bar</strong> ' +
31+
const input = '*Foo* $ 1 + 1 = 2 $ **Bar** $$ 2 + 2 = 4 $$'
32+
const expected = '<p><em>Foo</em> $ 1 + 1 = 2 $ <strong>Bar</strong> ' +
3333
'$$ 2 + 2 = 4 $$</p>\n'
3434
assert.deepStrictEqual(texme.render(input), expected)
3535
})
3636

3737
it('protected math', function () {
38-
var input = '$$ {a}_{1} {a}_{2} $$'
39-
var expected = '<p>$$ {a}_{1} {a}_{2} $$</p>\n'
38+
const input = '$$ {a}_{1} {a}_{2} $$'
39+
const expected = '<p>$$ {a}_{1} {a}_{2} $$</p>\n'
4040
texme.setOption('protectMath', true)
4141
assert.deepStrictEqual(texme.render(input), expected)
4242
texme.setDefaultOptions()
4343
})
4444

4545
it('unprotected math', function () {
46-
var input = '$$ {a}_{1} {a}_{2} $$'
47-
var expected = '<p>$$ {a}<em>{1} {a}</em>{2} $$</p>\n'
46+
const input = '$$ {a}_{1} {a}_{2} $$'
47+
const expected = '<p>$$ {a}<em>{1} {a}</em>{2} $$</p>\n'
4848
texme.setOption('protectMath', false)
4949
assert.deepStrictEqual(texme.render(input), expected)
5050
texme.setDefaultOptions()
5151
})
5252

5353
it('multiple lines', function () {
54-
var input =
54+
const input =
5555
'Binomial Theorem\n' +
5656
'----------------\n' +
5757
'$$ (x + y)^n = \\sum_{k=0}^n {n \\choose k} x^{n - k} y^k $$\n' +
@@ -60,7 +60,7 @@ describe('render', function () {
6060
'--------------------\n' +
6161
'\\[ e^x = \\lim_{n \\to \\infty} ' +
6262
'\\left( 1+ \\frac{x}{n} \\right)^n \\]\n'
63-
var expected =
63+
const expected =
6464
'<h2 id="binomial-theorem">Binomial Theorem</h2>\n' +
6565
'<p>$$ (x + y)^n = \\sum_{k=0}^n {n \\choose k} ' +
6666
'x^{n - k} y^k $$</p>\n' +

0 commit comments

Comments
 (0)