vscode-textmate icon indicating copy to clipboard operation
vscode-textmate copied to clipboard

Format strings not being handled in grammar

Open fabioz opened this issue 8 years ago • 3 comments

Given the grammar:

https://github.com/textmate/markdown.tmbundle/blob/master/Syntaxes/Markdown.tmLanguage it seems that vscode can't properly handle the construct https://github.com/textmate/markdown.tmbundle/blob/master/Syntaxes/Markdown.tmLanguage#L105

i.e.: when parsing a markdown with '##' with this construct (markup.heading.${1/(#)(#)?(#)?(#)?(#)?(#)?/${6:?6:${5:?5:${4:?4:${3:?3:${2:?2:1}}}}}/}.markdown), it'd be expected that the result is markup.heading.2.markdown, whereas vscode is just giving markup.heading.${1/(#)(#)?(#)?(#)?(#)?(#)?/${6:?6:${5:?5:${4:?4:${3:?3:${2:?2:1}}}}}/}.markdown as the result.

fabioz avatar Jun 15 '17 10:06 fabioz

@fabioz Do you happen to know how one should interpret / substitute ${1/(#)(#)?(#)?(#)?(#)?(#)?/${6:?6:${5:?5:${4:?4:${3:?3:${2:?2:1}}}}}/}

i.e. what does it mean ?

https://github.com/textmate/markdown.tmbundle/blob/7a8ff34351f96d0a2c15b0f6fe1b0c7091fb08a2/Syntaxes/Markdown.tmLanguage#L105

alexdima avatar Aug 23 '17 14:08 alexdima

From your comments at https://github.com/eclipse/tm4e/issues/116

  • suppose the begin captured ##.
  • ${1} is '##'.
  • then proceed to match ## against (#)(#)?(#)?(#)?(#)?(#)? and replace with ${6:?6:${5:?5:${4:?4:${3:?3:${2:?2:1}}}}}
    • ${6} through ${3} are '' (empty string)
    • ${2} is '#'
    • so the expression resolves to 2.

whoaaa

alexdima avatar Aug 23 '17 14:08 alexdima

I think this whould vastly simplify @mjbvz's https://github.com/mjbvz/vscode-comment-tagged-templates/blob/master/syntaxes/grammar.json.

texastoland avatar Sep 06 '21 20:09 texastoland