Skip to content

Commit 59737f6

Browse files
committed
fix(column_heading): alwasy check 0 columned
Fixes #5
1 parent 41ac505 commit 59737f6

File tree

6 files changed

+404
-251
lines changed

6 files changed

+404
-251
lines changed

corpus/code_block.txt

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ Simple code block
77
--------------------------------------------------------------------------------
88

99
(help_file
10-
(line
11-
(code_block)))
10+
(code_block))
1211

1312
================================================================================
1413
Code block with text before
@@ -34,6 +33,65 @@ Blehke
3433
--------------------------------------------------------------------------------
3534

3635
(help_file
36+
(code_block)
3737
(line
38-
(code_block)
3938
(word)))
39+
40+
================================================================================
41+
Strange codeblock
42+
================================================================================
43+
44+
Note that in the command: >
45+
:if "foo"
46+
:" NOT executed
47+
"foo" is converted to 0, which means FALSE. If the string starts with a
48+
non-zero number it means TRUE: >
49+
:if "8foo"
50+
:" executed
51+
To test for a non-empty string, use empty(): >
52+
:if !empty("foo")
53+
<
54+
55+
--------------------------------------------------------------------------------
56+
57+
(help_file
58+
(line
59+
(word)
60+
(word)
61+
(word)
62+
(word)
63+
(word)
64+
(code_block))
65+
(line
66+
(word)
67+
(word)
68+
(word)
69+
(word)
70+
(word)
71+
(word)
72+
(word)
73+
(word)
74+
(word)
75+
(word)
76+
(word)
77+
(word)
78+
(word)
79+
(word))
80+
(line
81+
(word)
82+
(word)
83+
(word)
84+
(word)
85+
(word)
86+
(word)
87+
(code_block))
88+
(line
89+
(word)
90+
(word)
91+
(word)
92+
(word)
93+
(word)
94+
(word)
95+
(word)
96+
(word)
97+
(code_block)))

grammar.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = grammar({
1212

1313
rules: {
1414
help_file: ($) =>
15-
repeat1(choice($.line, '\n', $.column_heading, $.headline)),
15+
repeat1(choice($.line, '\n', $.column_heading, $.headline, $.code_block)),
1616

1717
headline: ($) =>
1818
seq(
@@ -22,13 +22,12 @@ module.exports = grammar({
2222
'\n',
2323
),
2424

25-
line: ($) => prec.right(seq(repeat1($._atom), optional('\n'))),
25+
line: ($) => prec.right(seq(repeat1($._atom), optional($.code_block), optional('\n'))),
2626

2727
_atom: ($) =>
2828
choice(
2929
$.word,
3030
$.tag,
31-
$.code_block,
3231
$.tag,
3332
$.option,
3433
$.hotlink,

src/grammar.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
{
2222
"type": "SYMBOL",
2323
"name": "headline"
24+
},
25+
{
26+
"type": "SYMBOL",
27+
"name": "code_block"
2428
}
2529
]
2630
}
@@ -84,6 +88,18 @@
8488
"name": "_atom"
8589
}
8690
},
91+
{
92+
"type": "CHOICE",
93+
"members": [
94+
{
95+
"type": "SYMBOL",
96+
"name": "code_block"
97+
},
98+
{
99+
"type": "BLANK"
100+
}
101+
]
102+
},
87103
{
88104
"type": "CHOICE",
89105
"members": [
@@ -110,10 +126,6 @@
110126
"type": "SYMBOL",
111127
"name": "tag"
112128
},
113-
{
114-
"type": "SYMBOL",
115-
"name": "code_block"
116-
},
117129
{
118130
"type": "SYMBOL",
119131
"name": "tag"

src/node-types.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@
8888
"multiple": true,
8989
"required": false,
9090
"types": [
91+
{
92+
"type": "code_block",
93+
"named": true
94+
},
9195
{
9296
"type": "column_heading",
9397
"named": true

0 commit comments

Comments
 (0)