Skip to content

Commit

Permalink
feat: support @code and \c
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq committed Aug 31, 2023
1 parent 7ac6203 commit a750758
Show file tree
Hide file tree
Showing 8 changed files with 3,255 additions and 2,358 deletions.
26 changes: 21 additions & 5 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ module.exports = grammar({
description: $ => repeat1(choice(
$._text,
$.emphasis,
$.code_word,
$.link,
$.function_link,
)),
Expand Down Expand Up @@ -160,6 +161,8 @@ module.exports = grammar({

emphasis: $ => seq('\\a', alias(/[a-zA-Z_][a-zA-Z_0-9]*/, $.text)),

code_word: $ => seq('\\c', alias(/[a-zA-Z_][a-zA-Z_0-9]*/, $.code)),

link: $ => seq(
'<a',
/[^>]*/,
Expand All @@ -180,11 +183,24 @@ module.exports = grammar({
),
)),

code_block: $ => seq(
$.code_block_start,
$.code_block_language,
$.code_block_content,
$.code_block_end,
code_block: $ => choice(
seq(
$.code_block_start,
$.code_block_language,
$.code_block_content,
$.code_block_end,
),
seq(
'@code',
optional(seq(
token.immediate('{'),
token.immediate('.'),
$.code_block_language,
token.immediate('}'),
)),
$.code_block_content,
'@endcode',
),
),

_text: _ => token(prec(-1, /[^*{}@\\\s][^*!{}\\\n]*([^*/{}\\\n][^*{}\\\n]*\*+)*/)),
Expand Down
13 changes: 11 additions & 2 deletions queries/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
((tag_name) @keyword
(#set! "priority" 105))

[
"@code"
"@endcode"
] @keyword

(identifier) @variable

((tag
Expand All @@ -14,7 +19,10 @@

(emphasis) @text.emphasis

"\\a" @tag
[
"\\a"
"\\c"
] @tag

(code_block_language) @label

Expand All @@ -33,12 +41,13 @@
] @tag

[
"."
","
"::"
(code_block_start)
(code_block_end)
] @punctuation.delimiter

[ "(" ")" "[" "]" ] @punctuation.bracket
[ "(" ")" "{" "}" "[" "]" ] @punctuation.bracket

(code_block_content) @none
2 changes: 1 addition & 1 deletion queries/injections.scm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
((type) @injection.content
(#set! injection.parent))

((function_link) @injection.content
([ (function_link) (code) ] @injection.content
(#set! injection.parent))

((link) @injection.content
Expand Down
108 changes: 95 additions & 13 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a750758

Please sign in to comment.