Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go syntax highlighting in Markdown code block #1735

Closed
dgrisham opened this issue Nov 29, 2017 · 3 comments
Closed

Go syntax highlighting in Markdown code block #1735

dgrisham opened this issue Nov 29, 2017 · 3 comments

Comments

@dgrisham
Copy link

dgrisham commented Nov 29, 2017

Type: Bug

Severity: Low

Version: Not sure how to get the version via CLI, but whichever is in the AUR https://aur.archlinux.org/packages/kakoune-git. I just updated, but the issue was there prior to the update as well (and the last time I updated kakoune was at least a month ago).

Description

When writing a go code block in a markdown file, e.g.

```go
func f() { /* ... */ }
```

The entire code block, including the leading ```go and trailing ```, are treated as one big string literal (which start and end with backticks) which means everything is just a single color. My guess is that the issue is with the markdown.kak file rather than go.kak, since the highlighting inside a code block shouldn't be affected by the characters defining the block itself.

Edit Also note that the following modification, putting a ` after go fixes the highlighting inside the block (which isn't a solution, of course, but helps identify the issue):

```go`
func f() { /* ... */ }
```

Edit 2 Lot of backticks here, editing the formatting for clarity. Also, I suppose it likely isn't treating it as 'one big string literal', rather the first two backticks make an empty string literal, then the next backtick starts another, which is then closed by the first backtick in the closing ```, and finally the last two backticks in the closing trio make another empty string literal.

@dgrisham
Copy link
Author

I tried to make a hacky-ish solution based on my very primitive understanding of how highlighters work by editing this line from:

  go         ```\h*go         ```          '' \

to

  go         (?<=```\h*go)         ```          '' \

or even

  go         (?<=```go)$         ```          '' \

but no variation on these seem to work.

@mawww
Copy link
Owner

mawww commented Dec 10, 2017

@dgrisham I suspect

go ```\h*go\K    ```    ''

Will do the trick, you cannot use \h* in a lookaround with Kakoune's regex impl. I am wondering if the regex solution is good enough, or if we want to have another way to specify that the matched regex should not be taken as part of the region itself.

danr pushed a commit to danr/kakoune that referenced this issue Dec 10, 2017
Fixes mawww#1735

We need \K to not interfer with languages own interpretation of ` like multiline strings in javascript

We need \b in e.g. java\b otherwise it blocks javascript

I couldn't get the bare ``` to not block the other highlighters when introducing \K any other way than negative lookahead of all possible highlighers
@dgrisham
Copy link
Author

@mawww Nice, that (+ the other changes @danr made) work for me. Thanks! And yeah, it seems like it could be quite clean to be able to specify a region by either included or excluded boundaries -- especially since that might also take care of the comprehensive negative lookbehind that is needed at the moment, unless there's another way around that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants