Skip to content

Commit

Permalink
Merge pull request #125 from MDeiml/empty-pipe-table-cells
Browse files Browse the repository at this point in the history
Create node for pipe table cells containing only whitespace
  • Loading branch information
MDeiml authored Nov 11, 2023
2 parents 7ce4c69 + b9397f7 commit 192fbf2
Show file tree
Hide file tree
Showing 5 changed files with 30,123 additions and 30,063 deletions.
22 changes: 22 additions & 0 deletions tree-sitter-markdown/corpus/extension_pipe_table.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,25 @@ Example 205 - https://github.github.com/gfm/#example-205
(pipe_table_delimiter_row
(pipe_table_delimiter_cell)
(pipe_table_delimiter_cell)))))

================================================================================
#112 - Works with table cells that only contain whitespce
================================================================================
| foo | bar |
| --- | --- |
| | bim |

--------------------------------------------------------------------------------

(document
(section
(pipe_table
(pipe_table_header
(pipe_table_cell)
(pipe_table_cell))
(pipe_table_delimiter_row
(pipe_table_delimiter_cell)
(pipe_table_delimiter_cell))
(pipe_table_row
(pipe_table_cell)
(pipe_table_cell)))))
11 changes: 8 additions & 3 deletions tree-sitter-markdown/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,14 @@ module.exports = grammar({
choice(
seq(
repeat1(prec.right(seq(
optional($._whitespace),
optional($.pipe_table_cell),
optional($._whitespace),
choice(
seq(
optional($._whitespace),
$.pipe_table_cell,
optional($._whitespace)
),
alias($._whitespace, $.pipe_table_cell)
),
'|',
))),
optional($._whitespace),
Expand Down
65 changes: 38 additions & 27 deletions tree-sitter-markdown/src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -4673,35 +4673,46 @@
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_whitespace"
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "pipe_table_cell"
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_whitespace"
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_whitespace"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "pipe_table_cell"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_whitespace"
},
{
"type": "BLANK"
}
]
}
]
},
{
"type": "BLANK"
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_whitespace"
},
"named": true,
"value": "pipe_table_cell"
}
]
},
Expand Down
4 changes: 2 additions & 2 deletions tree-sitter-markdown/src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@
"fields": {},
"children": {
"multiple": true,
"required": false,
"required": true,
"types": [
{
"type": "pipe_table_cell",
Expand All @@ -614,7 +614,7 @@
"fields": {},
"children": {
"multiple": true,
"required": false,
"required": true,
"types": [
{
"type": "pipe_table_cell",
Expand Down
Loading

0 comments on commit 192fbf2

Please sign in to comment.