Skip to content

Commit d18004a

Browse files
committed
Remove test for punctuations for inline delimiters
Closes #19
1 parent ec93896 commit d18004a

File tree

4 files changed

+11
-33
lines changed

4 files changed

+11
-33
lines changed

dist/markdown-it-math.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5725,14 +5725,11 @@ require('./lib/polyfills');
57255725

57265726
function scanDelims(state, start, delimLength) {
57275727
var pos = start, lastChar, nextChar, count, can_open, can_close,
5728-
isLastWhiteSpace, isLastPunctChar,
5729-
isNextWhiteSpace, isNextPunctChar,
5728+
isLastWhiteSpace, isNextWhiteSpace,
57305729
left_flanking = true,
57315730
right_flanking = true,
57325731
max = state.posMax,
5733-
isWhiteSpace = state.md.utils.isWhiteSpace,
5734-
isPunctChar = state.md.utils.isPunctChar,
5735-
isMdAsciiPunct = state.md.utils.isMdAsciiPunct;
5732+
isWhiteSpace = state.md.utils.isWhiteSpace;
57365733

57375734
// treat beginning of the line as a whitespace
57385735
lastChar = start > 0 ? state.src.charCodeAt(start - 1) : 0x20;
@@ -5748,26 +5745,15 @@ function scanDelims(state, start, delimLength) {
57485745
// treat end of the line as a whitespace
57495746
nextChar = pos < max ? state.src.charCodeAt(pos) : 0x20;
57505747

5751-
isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
5752-
isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
5753-
57545748
isLastWhiteSpace = isWhiteSpace(lastChar);
57555749
isNextWhiteSpace = isWhiteSpace(nextChar);
57565750

57575751
if (isNextWhiteSpace) {
57585752
left_flanking = false;
5759-
} else if (isNextPunctChar) {
5760-
if (!(isLastWhiteSpace || isLastPunctChar)) {
5761-
left_flanking = false;
5762-
}
57635753
}
57645754

57655755
if (isLastWhiteSpace) {
57665756
right_flanking = false;
5767-
} else if (isLastPunctChar) {
5768-
if (!(isNextWhiteSpace || isNextPunctChar)) {
5769-
right_flanking = false;
5770-
}
57715757
}
57725758

57735759
can_open = left_flanking;

dist/markdown-it-math.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@ require('./lib/polyfills');
88

99
function scanDelims(state, start, delimLength) {
1010
var pos = start, lastChar, nextChar, count, can_open, can_close,
11-
isLastWhiteSpace, isLastPunctChar,
12-
isNextWhiteSpace, isNextPunctChar,
11+
isLastWhiteSpace, isNextWhiteSpace,
1312
left_flanking = true,
1413
right_flanking = true,
1514
max = state.posMax,
16-
isWhiteSpace = state.md.utils.isWhiteSpace,
17-
isPunctChar = state.md.utils.isPunctChar,
18-
isMdAsciiPunct = state.md.utils.isMdAsciiPunct;
15+
isWhiteSpace = state.md.utils.isWhiteSpace;
1916

2017
// treat beginning of the line as a whitespace
2118
lastChar = start > 0 ? state.src.charCodeAt(start - 1) : 0x20;
@@ -31,26 +28,15 @@ function scanDelims(state, start, delimLength) {
3128
// treat end of the line as a whitespace
3229
nextChar = pos < max ? state.src.charCodeAt(pos) : 0x20;
3330

34-
isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
35-
isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
36-
3731
isLastWhiteSpace = isWhiteSpace(lastChar);
3832
isNextWhiteSpace = isWhiteSpace(nextChar);
3933

4034
if (isNextWhiteSpace) {
4135
left_flanking = false;
42-
} else if (isNextPunctChar) {
43-
if (!(isLastWhiteSpace || isLastPunctChar)) {
44-
left_flanking = false;
45-
}
4636
}
4737

4838
if (isLastWhiteSpace) {
4939
right_flanking = false;
50-
} else if (isLastPunctChar) {
51-
if (!(isNextWhiteSpace || isNextPunctChar)) {
52-
right_flanking = false;
53-
}
5440
}
5541

5642
can_open = left_flanking;

test/fixtures/default.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ foo$$1+1 = 2$$bar
4141
<p>foo<math><mrow><mn>1</mn><mo>+</mo><mn>1</mn></mrow><mo>=</mo><mn>2</mn></math>bar</p>
4242
.
4343

44+
Same goes for punctuation
45+
.
46+
foo$$-2x < 4$$bar
47+
.
48+
<p>foo<math><mrow><mo>-</mo><mn>2</mn><mi>x</mi></mrow><mo>&lt;</mo><mn>4</mn></math>bar</p>
49+
.
4450

4551
Paragraph breaks are unnecessary before and after display math
4652
.

0 commit comments

Comments
 (0)