From f842daf7783b34c3590449d76b3b9d537fe88fe4 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Thu, 22 Aug 2024 16:13:19 -0400 Subject: [PATCH] Address feedback --- lib/blocks.js | 5 +++-- test/tables.txt | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/blocks.js b/lib/blocks.js index c1e5da8e..92f8a43a 100644 --- a/lib/blocks.js +++ b/lib/blocks.js @@ -57,6 +57,8 @@ var reLineEnding = /\r\n|\n|\r/; var reTableRow = /^(\|?)(?:(?:\\\||[^|])*\|?)+$/; +var reValidTableDelimiter = /^:?-+:?$/; + var MAX_AUTOCOMPLETED_CELLS = 1000; // Returns true if string contains only space characters. @@ -783,7 +785,7 @@ var blockStarts = [ } const nextColumn = measureNonspaceColumn(parser.nextLine); - if (nextColumn - parser.column >= CODE_INDENT || parser.column - nextColumn >= CODE_INDENT) { + if (Math.abs(nextColumn - parser.column) >= CODE_INDENT) { // the delimiter row must be on the same indentation level as the header row return 0; } @@ -867,7 +869,6 @@ var blockStarts = [ } ]; -const reValidTableDelimiter = /^:?-+:?$/; const parseDelimiterRow = function(row) { if (row.indexOf("|") === -1) { return null; diff --git a/test/tables.txt b/test/tables.txt index 249ab093..7d5270c0 100644 --- a/test/tables.txt +++ b/test/tables.txt @@ -1207,6 +1207,9 @@ Here's a link to [Freedom Planet 2][]. ### Invalid table (MM-55972/MM-59809) +This table is invalid because of the space in the middle of the third column +of the second line of the table (`:----------------- --------------:`). + ```````````````````````````````` example | A | B | C | | | | :--------------------------------: | :----------------------------: | :----------------- --------------: | :-----------: |:-----------: | @@ -1219,6 +1222,9 @@ Here's a link to [Freedom Planet 2][]. | | J | K | | |

```````````````````````````````` +This table is invalid because the last column of the delimiter row has no +dashes in it (`| |`). + ```````````````````````````````` example | 그룹명 | 자산합계1) | 주력업종1) 및 자산 | 비주력업종1) 및 자산 | 소속 금융회사2) | | | | | | ---- | ------ | ----------- | ------------ | --------- | ------ | ------ | --- | |