Skip to content

Commit

Permalink
fix: fix tabs at beginning of list items (#2679)
Browse files Browse the repository at this point in the history
* fix: fix tabs at beginning of list items

* test: add test for ordered list
  • Loading branch information
UziTech committed Dec 23, 2022
1 parent 1bbda68 commit e692634
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Tokenizer.js
Expand Up @@ -203,7 +203,7 @@ export class Tokenizer {
raw = cap[0];
src = src.substring(raw.length);

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

if (this.options.pedantic) {
Expand All @@ -225,7 +225,7 @@ export class Tokenizer {
}

if (!endEarly) {
const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?: [^\\n]*)?(?:\\n|$))`);
const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`);
const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
Expand Down
17 changes: 17 additions & 0 deletions test/specs/new/list_item_tabs.html
@@ -0,0 +1,17 @@
<ul>
<li>A</li>
<li>B</li>
<li>C</li>
<li>D</li>
<li>E</li>
<li>F</li>
</ul>

<ol>
<li>A</li>
<li>B</li>
<li>C</li>
<li>D</li>
<li>E</li>
<li>F</li>
</ol>
13 changes: 13 additions & 0 deletions test/specs/new/list_item_tabs.md
@@ -0,0 +1,13 @@
- A
- B
- C
- D
- E
- F

1. A
2. B
3. C
4. D
5. E
6. F

1 comment on commit e692634

@vercel
Copy link

@vercel vercel bot commented on e692634 Dec 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.