Skip to content

Commit db4d09b

Browse files
feat: simplify inline block parsing
1 parent e8630c5 commit db4d09b

File tree

6 files changed

+36325
-36001
lines changed

6 files changed

+36325
-36001
lines changed

grammar.js

+5-14
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const org_grammar = {
1616
$._sectionend,
1717
$._eof, // Basically just '\0', but allows multiple to be matched
1818
$._link_open,
19-
$._inline_code,
19+
$.error_sentinel
2020
],
2121

2222
inline: $ => [
@@ -96,23 +96,14 @@ const org_grammar = {
9696
priority: _ => token(/\[#\w+\]/),
9797

9898
inline_code_block: $ => seq(
99-
field('open', alias($._inline_block_open, $.open)),
99+
field('open', alias($._inline_code_open, $.open)),
100100
field('contents', alias(repeat($.expr), $.contents)),
101101
field('close', alias(choice(token('}'), token.immediate('}')), $.close))
102102
),
103103

104-
_inline_block_open: $ => seq(
105-
$._inline_code,
106-
token('src_'),
107-
field('language', alias(token.immediate(/\w+/), $.language)),
108-
optional(
109-
seq(
110-
token.immediate('['),
111-
field('parameters', alias(repeat(alias(/[^\r\n\p{Z}\]]+/, $.expr)), $.parameters)),
112-
']',
113-
),
114-
),
115-
token.immediate('{'),
104+
_inline_code_open: $ => choice(
105+
token(/src_([^\s\[\{]+)\{/),
106+
token(/src_[^\s\[\{]+\[[^\r\n\[\]]*\]\{/)
116107
),
117108

118109
// Can't have multiple in a row

src/grammar.json

+9-74
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/node-types.json

+1-45
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)