By the very nature of a comment, this might not make sense.
On the other hand, what I'm trying to achieve is not too different from an escape character.
As a simple example, I want
# comment :break: comment
to show up more like like
#comment
"break"
# comment
would, but without the second #
, everything is on the same line, and instead of quotes I have some other escape character. Although, like quotes (and unlike escape characters that I'm familiar with [e.g., \
]), I intend to explicitly indicate the beginning and the end of the interruption to the comment.
Thanks to @Graham P Heath, I was able to achieve alternate forms of comments in this question. What I'm after is an enhancement to what was achieved there. In my scenario, #
is a comment in the language I'm using (R), and #'
functions both as an R comment and as the start of code in another language. Now, I can get everything after the #'
to take on syntax highlighting that is different from the typical R comment, but I'm trying to get a very modest amount of syntax highlighting in this sub-language (#'
actually indicates the start of markdown code, and I want the "raw" syntax highlighting for text surround in a pair of ` ).
The piece of the language grammar that I'm trying to interrupt is as follows:
{ begin = '(^[ \t]+)?(?=#'' )';
end = '(?!\G)';
beginCaptures = { 1 = { name = 'punctuation.whitespace.comment.leading.r'; }; };
patterns = (
{ name = 'comment.line.number-sign-tick.r';
begin = "#' ";
end = '\n';
beginCaptures = { 0 = { name = 'punctuation.definition.comment.r'; }; };
},
);
},