You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The actual Kakoune script it generates looks something like this (at least, after PR #2400 lands):
add-highlighter shared/markdown/rust region -match-capture ^(\h*)```\h*rust\\b ^(\h*)``` regions
add-highlighter shared/markdown/rust/ default-region fill meta
add-highlighter shared/markdown/rust/inner region \A```[^\\n]*\K (?=```) ref rust
As I understand it, this means:
A Rust region starts from a line beginning with triple-backtick followed by rust, and ends with a line with the same indent containing a triple-quote.
That entire region, including the opening and closing markers, gets filled with the "meta" face.
The inner region, after the opening marker and before the closing marker, gets highlighted according to Rust rules.
There's just one problem: the inner region doesn't necessarily end before the closing marker, it ends before the first triple-backtick. So if I have a code-block like this:
```rust
fn main() {
// some comment with ``` in it
println!("hello, world");
}
```
...the Rust highlighting ends in the middle of the second line, instead of continuing until the end. The obvious solution is to change the region-end regex from (?=```) to (?=```\z) since we want to end the region when we hit the closing marker, not any old triple-backtick. Unfortunately, that solution produces an error:
'add-highlighter' regex parse error: Lookaround can only contain literals, any chars or character classes at (?=```\z)<<<HERE>>>
I know that Kakoune's non-backtracking regex-engine implies certain limitations about lookahead and lookbehind, but I vaguely recall the current implementation is overly restrictive. If this particular restriction is not entirely necessary, it would be great if it could be lifted.
Other alternatives that I can think of:
If there were some way to automatically apply a highlighter to the inside of a region (that is, between the text matched by the opening and closing regexes, without including them), that would be fine.
An opposite version of \K, that resets the end position of capture group 0 to the current position.
The text was updated successfully, but these errors were encountered:
Rust doc blocks already work (I forgot when but quite some time ago), I ported a similar version from rust.vim. It even checks checks for the correct term, like edition2018,no_run and also support # for hiding code. But I didn't add support for other languages.
The Markdown highlighter contains support for highlighting different languages in fenced code blocks, like this:
The actual Kakoune script it generates looks something like this (at least, after PR #2400 lands):
As I understand it, this means:
rust
, and ends with a line with the same indent containing a triple-quote.There's just one problem: the inner region doesn't necessarily end before the closing marker, it ends before the first triple-backtick. So if I have a code-block like this:
...the Rust highlighting ends in the middle of the second line, instead of continuing until the end. The obvious solution is to change the region-end regex from
(?=```)
to(?=```\z)
since we want to end the region when we hit the closing marker, not any old triple-backtick. Unfortunately, that solution produces an error:I know that Kakoune's non-backtracking regex-engine implies certain limitations about lookahead and lookbehind, but I vaguely recall the current implementation is overly restrictive. If this particular restriction is not entirely necessary, it would be great if it could be lifted.
Other alternatives that I can think of:
\K
, that resets the end position of capture group 0 to the current position.The text was updated successfully, but these errors were encountered: