Skip to content

Commit 7f9a7e5

Browse files
committed
feat: add (expr) in plan for non-matched generic text.
Also allow other characters in day names (#16)
1 parent 1c3eb53 commit 7f9a7e5

File tree

5 files changed

+9513
-8856
lines changed

5 files changed

+9513
-8856
lines changed

corpus/basic.tst

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2140,7 +2140,7 @@ Plan.8b - Junk
21402140
(expr)))))
21412141

21422142
================================================================================
2143-
Plan.9 - Expression
2143+
Plan.9 - TsExpression
21442144
================================================================================
21452145
* a
21462146
<%%(b)> [%%c]
@@ -2291,3 +2291,22 @@ Plan.14a - Successful
22912291
(entry_name)
22922292
(timestamp
22932293
(date))))))
2294+
2295+
================================================================================
2296+
Plan.15 - Expr
2297+
================================================================================
2298+
* a
2299+
<1-1-1 *123>
2300+
--------------------------------------------------------------------------------
2301+
2302+
(document
2303+
(section
2304+
(headline
2305+
(stars)
2306+
(item
2307+
(expr)))
2308+
(plan
2309+
(entry
2310+
(timestamp
2311+
(date)
2312+
(expr))))))

grammar.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,12 @@ org_grammar = {
161161
date: $ => /\p{N}{1,4}-\p{N}{1,4}-\p{N}{1,4}/,
162162

163163
_ts_element: $ => choice(
164-
alias(/\p{L}+/, $.day),
164+
alias(/\p{L}[^\]>\p{Z}\n\r]*/, $.day),
165165
alias(/\p{N}?\p{N}[:.]\p{N}\p{N}( ?\p{L}{1,2})?/, $.time),
166166
alias(/\p{N}?\p{N}[:.]\p{N}\p{N}( ?\p{L}{1,2})?-\p{N}?\p{N}[:.]\p{N}\p{N}( ?\p{L}{1,2})?/, $.duration),
167167
alias(/[.+]?\+\p{N}+\p{L}/, $.repeat),
168168
alias(/--?\p{N}+\p{L}/, $.delay),
169+
alias(prec(-1, /[^\]>\p{Z}\n\r]+/), $.expr),
169170
),
170171

171172
paragraph: $ => seq(optional($._directive_list), $._multiline_text),

src/grammar.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@
786786
"type": "ALIAS",
787787
"content": {
788788
"type": "PATTERN",
789-
"value": "\\p{L}+"
789+
"value": "\\p{L}[^\\]>\\p{Z}\\n\\r]*"
790790
},
791791
"named": true,
792792
"value": "day"
@@ -826,6 +826,19 @@
826826
},
827827
"named": true,
828828
"value": "delay"
829+
},
830+
{
831+
"type": "ALIAS",
832+
"content": {
833+
"type": "PREC",
834+
"value": -1,
835+
"content": {
836+
"type": "PATTERN",
837+
"value": "[^\\]>\\p{Z}\\n\\r]+"
838+
}
839+
},
840+
"named": true,
841+
"value": "expr"
829842
}
830843
]
831844
},

src/node-types.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,10 @@
795795
"type": "duration",
796796
"named": true
797797
},
798+
{
799+
"type": "expr",
800+
"named": true
801+
},
798802
{
799803
"type": "repeat",
800804
"named": true

0 commit comments

Comments
 (0)