Support argument placeholders for nested command definition (#161)

When defining a command within other command, the arguments
are accessed by doubling the `#` sign.

Signed-off-by: Jonas Dujava <jonas.dujava@gmail.com>
pull/813/head
Jonáš Dujava 2024-08-18 18:12:20 +07:00 committed by GitHub
parent 0422e78fb5
commit 90fd9894be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 31 additions and 2 deletions

@ -386,7 +386,7 @@ module.exports = grammar({
word: $ => /[^\s\\%\{\},\$\[\]\(\)=\#&_\^\-\+\/\*]+/,
placeholder: $ => /#\d/,
placeholder: $ => /#+\d/,
delimiter: $ => /&/,

@ -1673,7 +1673,7 @@
},
"placeholder": {
"type": "PATTERN",
"value": "#\\d"
"value": "#+\\d"
},
"delimiter": {
"type": "PATTERN",

@ -195,6 +195,35 @@ Command definition with optional argument (xparse)
(placeholder)
(placeholder)))))
================================================================================
Nested command definition with arguments
================================================================================
\NewDocumentCommand{\foo}{m}{
\DeclareDocumentCommand{\bar}{m}{#1, ##1}
}
--------------------------------------------------------------------------------
(source_file
(new_command_definition
(curly_group_command_name
(command_name))
(curly_group_spec
(text
(word)))
(curly_group
(new_command_definition
(curly_group_command_name
(command_name))
(curly_group_spec
(text
(word)))
(curly_group
(text
(placeholder))
(text
(placeholder)))))))
================================================================================
Command copy (of command defined in grammar which requires a following node)
================================================================================