Skip to content

Commit

Permalink
docs: added documentation and test code for math syntax OK/NG cases
Browse files Browse the repository at this point in the history
  • Loading branch information
akabekobeko committed Apr 24, 2021
1 parent 5d40c12 commit 218ad29
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
6 changes: 3 additions & 3 deletions docs/vfm.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,14 @@ OK:

- `$...$`, `$$...$$` ...Range specification matches
- `$...\n...$`, `$$\n...\n$$` ...Within the same paragraph
- `$...\$...$`, `$$...\$...$$` ...Escape `$` by `\`
- `$...\$...$`, `$...\$...\\\$..$`, `$$...\$...\\\$...$$` ...Escape `$` by odd `\`

NG:

- `$...$$`, `$$...$` ...Range specification does not match
- `$...\n\n...$`, `$$...\n\n...$$` ...Split paragraph
- `$ ...$` ...Space ` ` immediately after `$` at start of inline
- `$... $` ...Space ` ` immediately before `$` at end of inline
- `$ ...$` ...Spaces (space, tab, new line, ...etc) ` ` immediately after `$` at start of inline
- `$... $` ...Spaces (space, tab, new line, ...etc) ` ` immediately before `$` at end of inline
- `$...$5` ...Digit `0...N` immediately after `$` at end of inline

**VFM**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"release": "release-it",
"release:pre": "release-it --preRelease --npm.tag=latest",
"test": "jest",
"test:debug": "jest tests/math.test.ts --silent=false --verbose false"
"test:debug": "jest tests/xxx.test.ts --silent=false --verbose false"
},
"dependencies": {
"debug": "^4.3.1",
Expand Down
14 changes: 9 additions & 5 deletions tests/math.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ const options = {

it('inline', () => {
const md = `text$x = y$text
$a$
$(x = y)$
$|x = y|$`;
const received = stringify(md, options);
const expected = `<p>text<span class="math inline">\\(x = y\\)</span>text
<span class="math inline">\\(a\\)</span>
<span class="math inline">\\((x = y)\\)</span>
<span class="math inline">\\(|x = y|\\)</span></p>`;
expect(received).toBe(expected);
Expand Down Expand Up @@ -62,10 +64,10 @@ it('inline: ignore "$" with number', () => {
});

it('inline: ignore "$.\\$.$"', () => {
const md = 'text $x = 5\\$ + 4$ text';
const md = 'text $x = 5\\$ + \\\\\\$ + 4$ text';
const received = stringify(md, options);
const expected =
'<p>text <span class="math inline">\\(x = 5\\$ + 4\\)</span> text</p>';
'<p>text <span class="math inline">\\(x = 5\\$ + \\\\\\$ + 4\\)</span> text</p>';
expect(received).toBe(expected);
});

Expand All @@ -77,9 +79,11 @@ it('inline: exclusive other markdown syntax', () => {
});

it('display', () => {
const received = stringify('text$$1 + 1 = 2$$text', options);
const expected =
'<p>text<span class="math display">$$1 + 1 = 2$$</span>text</p>';
const md = `text$$1 + 1 = 2$$text
$$a$$`;
const received = stringify(md, options);
const expected = `<p>text<span class="math display">$$1 + 1 = 2$$</span>text
<span class="math display">$$a$$</span></p>`;
expect(received).toBe(expected);
});

Expand Down

0 comments on commit 218ad29

Please sign in to comment.