From ec8cc7101d2d5d96e3adc9bcad8f27513ee6b375 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Wed, 7 Dec 2022 02:03:39 -0600 Subject: [PATCH 1/2] fix: fix tabs at beginning of list items --- src/Tokenizer.js | 4 ++-- test/specs/new/list_item_tabs.html | 8 ++++++++ test/specs/new/list_item_tabs.md | 6 ++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 test/specs/new/list_item_tabs.html create mode 100644 test/specs/new/list_item_tabs.md diff --git a/src/Tokenizer.js b/src/Tokenizer.js index d08d53ddc6..e219debf73 100644 --- a/src/Tokenizer.js +++ b/src/Tokenizer.js @@ -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) { @@ -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)}}#`); diff --git a/test/specs/new/list_item_tabs.html b/test/specs/new/list_item_tabs.html new file mode 100644 index 0000000000..8abfdabbe2 --- /dev/null +++ b/test/specs/new/list_item_tabs.html @@ -0,0 +1,8 @@ + diff --git a/test/specs/new/list_item_tabs.md b/test/specs/new/list_item_tabs.md new file mode 100644 index 0000000000..a404afc1f0 --- /dev/null +++ b/test/specs/new/list_item_tabs.md @@ -0,0 +1,6 @@ +- A +- B +- C +- D +- E +- F \ No newline at end of file From 269e83278f641cb9eb4a7d1588fe3ab3e1785ec8 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Wed, 14 Dec 2022 02:02:50 -0600 Subject: [PATCH 2/2] test: add test for ordered list --- test/specs/new/list_item_tabs.html | 9 +++++++++ test/specs/new/list_item_tabs.md | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/test/specs/new/list_item_tabs.html b/test/specs/new/list_item_tabs.html index 8abfdabbe2..e1b33013ea 100644 --- a/test/specs/new/list_item_tabs.html +++ b/test/specs/new/list_item_tabs.html @@ -6,3 +6,12 @@
  • E
  • F
  • + +
      +
    1. A
    2. +
    3. B
    4. +
    5. C
    6. +
    7. D
    8. +
    9. E
    10. +
    11. F
    12. +
    diff --git a/test/specs/new/list_item_tabs.md b/test/specs/new/list_item_tabs.md index a404afc1f0..b42c88b8cc 100644 --- a/test/specs/new/list_item_tabs.md +++ b/test/specs/new/list_item_tabs.md @@ -3,4 +3,11 @@ - C - D - E -- F \ No newline at end of file +- F + +1. A +2. B +3. C +4. D +5. E +6. F