nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: zestedesavoir/zmarkdown
Pull request #306 (2018-12-23 16:58:27)

remark-grid-tables: fix spaces on  lines


Patch:
diff --git a/packages/remark-grid-tables/dist/index.js b/packages/remark-grid-tables/dist/index.js
index 5c332455..063f16ef 100644
--- a/packages/remark-grid-tables/dist/index.js
+++ b/packages/remark-grid-tables/dist/index.js
@@ -325,7 +325,7 @@ function extractTable(value, eat, tokenizer) {
   for (; i < possibleGridTable.length; i++) {
     var _line2 = possibleGridTable[i];
     if (_line2.length === 0) break;
-    after.push(_line2);
+    after.push(markdownLines[i]);
   }
 
   return [before, gridTable, after, hasHeader];
@@ -757,8 +757,8 @@ function plugin() {
   // Inject blockTokenizer
   var blockTokenizers = Parser.prototype.blockTokenizers;
   var blockMethods = Parser.prototype.blockMethods;
-  blockTokenizers.grid_table = gridTableTokenizer;
-  blockMethods.splice(blockMethods.indexOf('fencedCode') + 1, 0, 'grid_table');
+  blockTokenizers.gridTable = gridTableTokenizer;
+  blockMethods.splice(blockMethods.indexOf('fencedCode') + 1, 0, 'gridTable');
 
   var Compiler = this.Compiler;
 
diff --git a/packages/remark-grid-tables/src/index.js b/packages/remark-grid-tables/src/index.js
index 1bc486c4..3d40c4d0 100644
--- a/packages/remark-grid-tables/src/index.js
+++ b/packages/remark-grid-tables/src/index.js
@@ -281,7 +281,7 @@ function extractTable (value, eat, tokenizer) {
   for (; i < possibleGridTable.length; i++) {
     const line = possibleGridTable[i]
     if (line.length === 0) break
-    after.push(line)
+    after.push(markdownLines[i])
   }
 
   return [before, gridTable, after, hasHeader]
@@ -694,8 +694,8 @@ function plugin () {
   // Inject blockTokenizer
   const blockTokenizers = Parser.prototype.blockTokenizers
   const blockMethods = Parser.prototype.blockMethods
-  blockTokenizers.grid_table = gridTableTokenizer
-  blockMethods.splice(blockMethods.indexOf('fencedCode') + 1, 0, 'grid_table')
+  blockTokenizers.gridTable = gridTableTokenizer
+  blockMethods.splice(blockMethods.indexOf('fencedCode') + 1, 0, 'gridTable')
 
   const Compiler = this.Compiler
 


Test patch:
diff --git a/packages/remark-grid-tables/__tests__/index.js b/packages/remark-grid-tables/__tests__/index.js
index bf3c90f5..53727adf 100644
--- a/packages/remark-grid-tables/__tests__/index.js
+++ b/packages/remark-grid-tables/__tests__/index.js
@@ -111,6 +111,30 @@ test('regression: should not crash with leading space', () => {
   expect(contents).toBe(base.replace('x', ' '))
 })
 
+test('regression: should not crash when followed by "sth<space>"', () => {
+  const {contents: base} = render(dedent`
+    +---+
+    | A |
+    +===+
+    | B |
+    +---+
+    <-
+    bug
+    `)
+
+  const {contents} = render(dedent`
+    +---+
+    | A |
+    +===+
+    | B |
+    +---+
+    <-·
+    bug
+    `.replace(/·/g, ' '))
+
+  expect(contents).toBe(base)
+})
+
 
 test('stringify', () => {
   const fileExample = file(join(__dirname, 'grid-tables.md'))