mawww / kakoune

mawww's experiment for a better code editor
http://kakoune.org
The Unlicense
9.7k stars 705 forks source link

[BUG] rendering issue in asciidoc with nested stars and backticks #5198

Open lobre opened 3 days ago

lobre commented 3 days ago

Version of Kakoune

80fcfebca8c62ace6cf2af9487784486af07d2d5

Reproducer

From within Kakoune, open the execeval doc.

:doc execeval

Then, scroll to the -buffer flag explanation.

Outcome

image

The asciidoc syntax is not rendered correctly. We see that the star disappeared at the beginning of the second sentence, and there is more bold than desired.

Expectations

If I check the source code, here it is:

*-buffer* <names>::
    Execute in the context of each buffer specified in the comma separated
    list *names*. `*` can be used as a *name* to iterate over all non-debug
    buffers.

So it should render like below instead:

* can be used as a name

Additional information

I tried playing with the asciidoc playground there: https://asciidoc.org/#try

But I cannot find a way to have a star in a block quote, plus "name" rendered as bold at the end.

I have tried:

# The first star is ok, but *name* appears as is, enclosed by stars and without being bold
`\*` can be used as a *name*

# It works, except that I have a pound sign instead of the desired star at the beginning
`#` can be used as a *name*

# The whole line is bold, and the first and last stars are not present anymore
`*` can be used as a *name*
arachsys commented 2 days ago

The rendering in kak's help mode is done by a handful of regex matches in doc-render in rc/tools/doc.kak and it looks to me as if the contents of `code quotes` aren't excluded properly from processing for things like *bold* and _italic_. The region highlighters used for normal syntax highlighting would be able to express this nicely because they can recurse, but as far as I know, they don't support removing the `...`, *...* or _..._ wrappers as the same point as highlighting them.

arachsys commented 2 days ago

I wonder if selections could be used in a cleverer way to solve this? Select all the `code quotes` and transform+highlight them. Then subtract those selections from the buffer before doing the transform+highlight for *bold* and _italic_? Something like that anyway!