fix: case insensitive syntax (#7)
This commit is contained in:
parent
bb238e37a1
commit
049e3861e1
5 changed files with 1565 additions and 1445 deletions
|
|
@ -238,6 +238,25 @@ PropertyDrawer.2 -
|
|||
|
||||
----------
|
||||
|
||||
(document
|
||||
(section
|
||||
(headline
|
||||
(stars)
|
||||
(item))
|
||||
(property_drawer
|
||||
(property))
|
||||
))
|
||||
|
||||
===================
|
||||
PropertyDrawer.2 - Lowercase
|
||||
===================
|
||||
* a
|
||||
:properties:
|
||||
:a: b
|
||||
:end:
|
||||
|
||||
----------
|
||||
|
||||
(document
|
||||
(section
|
||||
(headline
|
||||
|
|
@ -571,6 +590,20 @@ DEADLINE: <1111-11-11 Day> <1111-11-11 Day> CLOSED: [1111-11-11 Day]
|
|||
(closed (timestamp (date))))
|
||||
))
|
||||
|
||||
==========
|
||||
Plan.4 - Lowercase
|
||||
==========
|
||||
* headline
|
||||
scheduled: <1111-11-11 Day>
|
||||
|
||||
----------
|
||||
|
||||
(document
|
||||
(section
|
||||
(headline (stars) (item))
|
||||
(plan (scheduled (timestamp (date))))
|
||||
))
|
||||
|
||||
==========
|
||||
Drawer.1
|
||||
==========
|
||||
|
|
@ -633,6 +666,15 @@ a
|
|||
(block (name) (parameters) (contents))
|
||||
)))
|
||||
|
||||
==========
|
||||
Block.4 - lowercase
|
||||
==========
|
||||
#+begin_b
|
||||
#+end_b
|
||||
----------
|
||||
|
||||
(document (body (block (name))))
|
||||
|
||||
=================
|
||||
DynamicBlock.1 -
|
||||
=================
|
||||
|
|
@ -1478,6 +1520,16 @@ a
|
|||
|
||||
(document (body (latex_env (contents))))
|
||||
|
||||
=============
|
||||
LatexEnv.5 - Uppercase
|
||||
=============
|
||||
\begin{a}
|
||||
\end{a}
|
||||
|
||||
----------
|
||||
|
||||
(document (body (latex_env)))
|
||||
|
||||
==================
|
||||
LatexFragment.1 -
|
||||
==================
|
||||
|
|
|
|||
44
grammar.js
44
grammar.js
|
|
@ -156,9 +156,9 @@ org_grammar = {
|
|||
tag: _ => token.immediate(/[\p{L}\p{N}_@#%]+/),
|
||||
|
||||
property_drawer: $ => seq(
|
||||
':PROPERTIES:',
|
||||
caseInsensitive(':PROPERTIES:'),
|
||||
sep1(repeat1($._nl), $.property),
|
||||
':END:',
|
||||
caseInsensitive(':END:'),
|
||||
$._eol,
|
||||
),
|
||||
|
||||
|
|
@ -171,9 +171,9 @@ org_grammar = {
|
|||
|
||||
// Planning ============================================ {{{1
|
||||
|
||||
_scheduled: _ => 'SCHEDULED:',
|
||||
_deadline: _ => 'DEADLINE:',
|
||||
_closed: _ => 'CLOSED:',
|
||||
_scheduled: _ => caseInsensitive('SCHEDULED:'),
|
||||
_deadline: _ => caseInsensitive('DEADLINE:'),
|
||||
_closed: _ => caseInsensitive('CLOSED:'),
|
||||
|
||||
plan: $ => seq(
|
||||
repeat1(prec(1, // precedence over paragraph→timestamp
|
||||
|
|
@ -336,7 +336,7 @@ org_grammar = {
|
|||
// Footnote ============================================ {{{1
|
||||
|
||||
_fn_label: _ => /[\p{L}\p{N}_-]+/,
|
||||
_fn: _ => '[fn:',
|
||||
_fn: _ => caseInsensitive('[fn:'),
|
||||
|
||||
fndef: $ => prec('fn_definition',
|
||||
seq(
|
||||
|
|
@ -386,7 +386,7 @@ org_grammar = {
|
|||
),
|
||||
|
||||
_drawer_begin: $ => seq(':', $._drawername, token.immediate(':'), $._nl),
|
||||
_drawer_end: $ => seq(':END:', $._eol),
|
||||
_drawer_end: $ => seq(caseInsensitive(':END:'), $._eol),
|
||||
_drawername: _ => token.immediate(/[\p{L}\p{N}\p{Pd}\p{Pc}]+/),
|
||||
|
||||
// Block =============================================== {{{1
|
||||
|
|
@ -399,16 +399,13 @@ org_grammar = {
|
|||
),
|
||||
|
||||
_block_begin: $ => seq(
|
||||
'#+BEGIN_',
|
||||
caseInsensitive('#+BEGIN_'),
|
||||
alias($._name, $.name),
|
||||
optional(alias(repeat1($._text), $.parameters)),
|
||||
$._eol,
|
||||
),
|
||||
|
||||
_block_end: $ => seq(
|
||||
'#+END_', $._name,
|
||||
$._eol,
|
||||
),
|
||||
_block_end: $ => seq(caseInsensitive('#+END_'), $._name, $._eol),
|
||||
|
||||
_name: _ => token.immediate(/[^\p{Z}\n\r]+/),
|
||||
|
||||
|
|
@ -422,14 +419,14 @@ org_grammar = {
|
|||
),
|
||||
|
||||
_dynamic_begin: $ => seq(
|
||||
'#+BEGIN:',
|
||||
caseInsensitive('#+BEGIN:'),
|
||||
alias(/[^\p{Z}\n\r]+/, $.name),
|
||||
optional(alias(repeat1($._text), $.parameters)),
|
||||
$._eol,
|
||||
),
|
||||
|
||||
_dynamic_end: $ => seq(
|
||||
'#+END:',
|
||||
caseInsensitive('#+END:'),
|
||||
$._eol,
|
||||
),
|
||||
|
||||
|
|
@ -482,7 +479,7 @@ org_grammar = {
|
|||
$._eol,
|
||||
),
|
||||
|
||||
formula: $ => seq('#+TBLFM:', field('formula', repeat($._text)), $._eol),
|
||||
formula: $ => seq(caseInsensitive('#+TBLFM:'), field('formula', repeat($._text)), $._eol),
|
||||
|
||||
// Latex environment =================================== {{{1
|
||||
|
||||
|
|
@ -494,14 +491,14 @@ org_grammar = {
|
|||
),
|
||||
|
||||
_env_begin: $ => seq(
|
||||
'\\begin{',
|
||||
caseInsensitive('\\begin{'),
|
||||
field('name', /[\p{L}\p{N}]+/),
|
||||
token.immediate('}'),
|
||||
$._eol
|
||||
),
|
||||
|
||||
_env_end: $ => seq(
|
||||
'\\end{',
|
||||
caseInsensitive('\\end{'),
|
||||
/[\p{L}\p{N}]+/,
|
||||
token.immediate('}'),
|
||||
$._eol
|
||||
|
|
@ -538,6 +535,19 @@ org_grammar = {
|
|||
function sep1(rule, separator) { // {{{1
|
||||
return seq(rule, repeat(seq(separator, rule)))
|
||||
}
|
||||
|
||||
function caseInsensitive(str) { // {{{1
|
||||
return new RegExp(str
|
||||
.split('')
|
||||
.map(caseInsensitiveChar)
|
||||
.join('')
|
||||
)
|
||||
}
|
||||
|
||||
function caseInsensitiveChar(char) {
|
||||
if (/[a-zA-Z]/.test(char)) return `[${char.toUpperCase()}${char.toLowerCase()}]`;
|
||||
return char.replace(/[\[\]^$.|?*+()\\\{\}]/, '\\$&');
|
||||
}
|
||||
// }}}
|
||||
|
||||
module.exports = grammar(org_grammar);
|
||||
|
|
|
|||
|
|
@ -568,8 +568,8 @@
|
|||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ":PROPERTIES:"
|
||||
"type": "PATTERN",
|
||||
"value": ":[Pp][Rr][Oo][Pp][Ee][Rr][Tt][Ii][Ee][Ss]:"
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
|
|
@ -603,8 +603,8 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ":END:"
|
||||
"type": "PATTERN",
|
||||
"value": ":[Ee][Nn][Dd]:"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
|
|
@ -643,16 +643,16 @@
|
|||
]
|
||||
},
|
||||
"_scheduled": {
|
||||
"type": "STRING",
|
||||
"value": "SCHEDULED:"
|
||||
"type": "PATTERN",
|
||||
"value": "[Ss][Cc][Hh][Ee][Dd][Uu][Ll][Ee][Dd]:"
|
||||
},
|
||||
"_deadline": {
|
||||
"type": "STRING",
|
||||
"value": "DEADLINE:"
|
||||
"type": "PATTERN",
|
||||
"value": "[Dd][Ee][Aa][Dd][Ll][Ii][Nn][Ee]:"
|
||||
},
|
||||
"_closed": {
|
||||
"type": "STRING",
|
||||
"value": "CLOSED:"
|
||||
"type": "PATTERN",
|
||||
"value": "[Cc][Ll][Oo][Ss][Ee][Dd]:"
|
||||
},
|
||||
"plan": {
|
||||
"type": "SEQ",
|
||||
|
|
@ -1831,8 +1831,8 @@
|
|||
"value": "[\\p{L}\\p{N}_-]+"
|
||||
},
|
||||
"_fn": {
|
||||
"type": "STRING",
|
||||
"value": "[fn:"
|
||||
"type": "PATTERN",
|
||||
"value": "\\[[Ff][Nn]:"
|
||||
},
|
||||
"fndef": {
|
||||
"type": "PREC",
|
||||
|
|
@ -2135,8 +2135,8 @@
|
|||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ":END:"
|
||||
"type": "PATTERN",
|
||||
"value": ":[Ee][Nn][Dd]:"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
|
|
@ -2192,8 +2192,8 @@
|
|||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "#+BEGIN_"
|
||||
"type": "PATTERN",
|
||||
"value": "#\\+[Bb][Ee][Gg][Ii][Nn]_"
|
||||
},
|
||||
{
|
||||
"type": "ALIAS",
|
||||
|
|
@ -2234,8 +2234,8 @@
|
|||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "#+END_"
|
||||
"type": "PATTERN",
|
||||
"value": "#\\+[Ee][Nn][Dd]_"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
|
|
@ -2295,8 +2295,8 @@
|
|||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "#+BEGIN:"
|
||||
"type": "PATTERN",
|
||||
"value": "#\\+[Bb][Ee][Gg][Ii][Nn]:"
|
||||
},
|
||||
{
|
||||
"type": "ALIAS",
|
||||
|
|
@ -2337,8 +2337,8 @@
|
|||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "#+END:"
|
||||
"type": "PATTERN",
|
||||
"value": "#\\+[Ee][Nn][Dd]:"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
|
|
@ -2641,8 +2641,8 @@
|
|||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "#+TBLFM:"
|
||||
"type": "PATTERN",
|
||||
"value": "#\\+[Tt][Bb][Ll][Ff][Mm]:"
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
|
|
@ -2702,8 +2702,8 @@
|
|||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "\\begin{"
|
||||
"type": "PATTERN",
|
||||
"value": "\\\\[Bb][Ee][Gg][Ii][Nn]\\{"
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
|
|
@ -2730,8 +2730,8 @@
|
|||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "\\end{"
|
||||
"type": "PATTERN",
|
||||
"value": "\\\\[Ee][Nn][Dd]\\{"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
|
|
|
|||
|
|
@ -852,26 +852,6 @@
|
|||
"type": "#+",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "#+BEGIN:",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "#+BEGIN_",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "#+END:",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "#+END_",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "#+TBLFM:",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "$",
|
||||
"named": false
|
||||
|
|
@ -904,14 +884,6 @@
|
|||
"type": "::",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": ":END:",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": ":PROPERTIES:",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "=",
|
||||
"named": false
|
||||
|
|
@ -936,14 +908,6 @@
|
|||
"type": "\\]",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "\\begin{",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "\\end{",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "]",
|
||||
"named": false
|
||||
|
|
|
|||
2822
src/parser.c
2822
src/parser.c
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue