fix: tabs not included in regexes (close #36)

This commit is contained in:
Emilia Simmons 2022-09-12 12:12:18 -04:00
parent 698bb1a343
commit eb1e080361
6 changed files with 180 additions and 433 deletions

View file

@ -1,7 +1,7 @@
[package]
name = "tree-sitter-org"
description = "org grammar for the tree-sitter parsing library"
version = "1.3.1"
version = "1.3.2"
keywords = ["incremental", "parsing", "org"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/milisims/tree-sitter-org"

View file

@ -2427,3 +2427,22 @@ Plan.16 - Link
body: (body
(paragraph
(expr)))))
================================================================================
Plan.17 - Tab
================================================================================
* a
a: <2-2-2>
--------------------------------------------------------------------------------
(document
subsection: (section
headline: (headline
stars: (stars)
item: (item
(expr)))
plan: (plan
(entry
name: (entry_name)
timestamp: (timestamp
date: (date))))))

View file

@ -172,12 +172,12 @@ org_grammar = {
date: $ => /\p{N}{1,4}-\p{N}{1,4}-\p{N}{1,4}/,
_ts_element: $ => choice(
field('day', alias(/\p{L}[^\]>\p{Z}\n\r]*/, $.day)),
field('day', alias(/\p{L}[^\]>\p{Z}\t\n\r]*/, $.day)),
field('time', alias(/\p{N}?\p{N}[:.]\p{N}\p{N}( ?\p{L}{1,2})?/, $.time)),
field('duration', 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)),
field('repeat', alias(/[.+]?\+\p{N}+\p{L}/, $.repeat)),
field('delay', alias(/--?\p{N}+\p{L}/, $.delay)),
alias(prec(-1, /[^\[<\]>\p{Z}\n\r]+/), $.expr),
alias(prec(-1, /[^\[<\]>\p{Z}\t\n\r]+/), $.expr),
),
paragraph: $ => seq(optional($._directive_list), $._multiline_text),
@ -186,7 +186,7 @@ org_grammar = {
optional($._directive_list),
seq(
caseInsensitive('[fn:'),
field('label', alias(/[^\p{Z}\n\r\]]+/, $.expr)),
field('label', alias(/[^\p{Z}\t\n\r\]]+/, $.expr)),
']',
),
field('description', alias($._multiline_text, $.description))
@ -356,7 +356,7 @@ function expr(pr, tfunc, skip = '') {
...asciiSymbols.filter(c => !skip.includes(c)).map(c => tfunc(prec(pr, c))),
alias(tfunc(prec(pr, /\p{L}+/)), 'str'),
alias(tfunc(prec(pr, /\p{N}+/)), 'num'),
alias(tfunc(prec(pr, /[^\p{Z}\p{L}\p{N}\n\r]/)), 'sym'),
alias(tfunc(prec(pr, /[^\p{Z}\p{L}\p{N}\t\n\r]/)), 'sym'),
// for checkboxes: ugly, but makes them work..
// alias(tfunc(prec(pr, 'x')), 'str'),
// alias(tfunc(prec(pr, 'X')), 'str'),

View file

@ -1,6 +1,6 @@
{
"name": "tree-sitter-org",
"version": "1.3.1",
"version": "1.3.2",
"description": "Org grammar for tree-sitter",
"main": "bindings/node",
"keywords": [

View file

@ -833,7 +833,7 @@
"type": "ALIAS",
"content": {
"type": "PATTERN",
"value": "\\p{L}[^\\]>\\p{Z}\\n\\r]*"
"value": "\\p{L}[^\\]>\\p{Z}\\t\\n\\r]*"
},
"named": true,
"value": "day"
@ -898,7 +898,7 @@
"value": -1,
"content": {
"type": "PATTERN",
"value": "[^\\[<\\]>\\p{Z}\\n\\r]+"
"value": "[^\\[<\\]>\\p{Z}\\t\\n\\r]+"
}
},
"named": true,
@ -961,7 +961,7 @@
"type": "ALIAS",
"content": {
"type": "PATTERN",
"value": "[^\\p{Z}\\n\\r\\]]+"
"value": "[^\\p{Z}\\t\\n\\r\\]]+"
},
"named": true,
"value": "expr"
@ -2407,7 +2407,7 @@
"value": "immediate",
"content": {
"type": "PATTERN",
"value": "[^\\p{Z}\\p{L}\\p{N}\\n\\r]"
"value": "[^\\p{Z}\\p{L}\\p{N}\\t\\n\\r]"
}
}
},
@ -2804,7 +2804,7 @@
"value": "immediate",
"content": {
"type": "PATTERN",
"value": "[^\\p{Z}\\p{L}\\p{N}\\n\\r]"
"value": "[^\\p{Z}\\p{L}\\p{N}\\t\\n\\r]"
}
}
},
@ -3199,7 +3199,7 @@
"value": "immediate",
"content": {
"type": "PATTERN",
"value": "[^\\p{Z}\\p{L}\\p{N}\\n\\r]"
"value": "[^\\p{Z}\\p{L}\\p{N}\\t\\n\\r]"
}
}
},
@ -3585,7 +3585,7 @@
"value": "non-immediate",
"content": {
"type": "PATTERN",
"value": "[^\\p{Z}\\p{L}\\p{N}\\n\\r]"
"value": "[^\\p{Z}\\p{L}\\p{N}\\t\\n\\r]"
}
}
},
@ -3970,7 +3970,7 @@
"value": "immediate",
"content": {
"type": "PATTERN",
"value": "[^\\p{Z}\\p{L}\\p{N}\\n\\r]"
"value": "[^\\p{Z}\\p{L}\\p{N}\\t\\n\\r]"
}
}
},
@ -4381,7 +4381,7 @@
"value": "non-immediate",
"content": {
"type": "PATTERN",
"value": "[^\\p{Z}\\p{L}\\p{N}\\n\\r]"
"value": "[^\\p{Z}\\p{L}\\p{N}\\t\\n\\r]"
}
}
},
@ -4788,7 +4788,7 @@
"value": "immediate",
"content": {
"type": "PATTERN",
"value": "[^\\p{Z}\\p{L}\\p{N}\\n\\r]"
"value": "[^\\p{Z}\\p{L}\\p{N}\\t\\n\\r]"
}
}
},

File diff suppressed because it is too large Load diff