Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create node for pipe table cells containing only whitespace #125

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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