Skip to content

Commit ec8cc71

Browse files
committed
fix: fix tabs at beginning of list items
1 parent edc857c commit ec8cc71

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/Tokenizer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export class Tokenizer {
203203
raw = cap[0];
204204
src = src.substring(raw.length);
205205

206-
line = cap[2].split('\n', 1)[0];
206+
line = cap[2].split('\n', 1)[0].replace(/^\t+/, (t) => ' '.repeat(3 * t.length));
207207
nextLine = src.split('\n', 1)[0];
208208

209209
if (this.options.pedantic) {
@@ -225,7 +225,7 @@ export class Tokenizer {
225225
}
226226

227227
if (!endEarly) {
228-
const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?: [^\\n]*)?(?:\\n|$))`);
228+
const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`);
229229
const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
230230
const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
231231
const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);

test/specs/new/list_item_tabs.html

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<ul>
2+
<li>A</li>
3+
<li>B</li>
4+
<li>C</li>
5+
<li>D</li>
6+
<li>E</li>
7+
<li>F</li>
8+
</ul>

test/specs/new/list_item_tabs.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- A
2+
- B
3+
- C
4+
- D
5+
- E
6+
- F

0 commit comments

Comments
 (0)