tree-sitter-grammars / tree-sitter-markdown

Markdown grammar for tree-sitter
MIT License
411 stars 52 forks source link

Incorrect formatting of `tick quoted text` #62

Closed David-Else closed 1 year ago

David-Else commented 2 years ago

Describe the bug

Code example

### Search

Search commands all operate on the `d` register by default. Use `"<char>` to operate on a different one.

| Key | Description                                 | Command            |
| --- | ------------------------------------------- | ------------------ |
| `a` | Search for regex pattern                    | `search`           |
| `?` | Search for previous pattern                 | `rsearch`          |
| `n` | Select next search match                    | `search_next`      |
| `N` | Select previous search match                | `search_prev`      |
| `*` | Use current selection as the search pattern | `search_selection` |

Expected behavior

As GitHub displays above

Actual behavior

In Helix (using the latest commit e375ba95ff9a12418f9b9e7c190f549d08b5380a):

Screenshot from 2022-09-29 09-42-39

Please also see: https://github.com/helix-editor/helix/issues/3849 , is it enough to update the Helix commit hash or do the queries need modification?

Chickenkeeper commented 2 years ago

The main offender seems to be angle brackets in tick quotes. For example that line containing "<char> gets formatted correctly as long as there's at most a single angle bracket, or the order of the brackets are reversed, regardless of whatever else is in the quote. If there's at least one < and one > somewhere in the quote, in that order, the highlighting breaks.

Backslashes also prevent the text inside the quote from being highlighted if it isn't immediately followed by a letter or number, but it doesn't seem to affect text around it the way the angle brackets do.

MDeiml commented 2 years ago

Stuff that looks like a html tag might "overrule" inline code. That's something that is VERY hard to fix with this parser. I can get into why, but that's a bit more complicated. Though there are some priority values that I can finetune, so getting the simple cases to work might be possible.

Code spans in tables should actually also be highlighted, but that error might be because tables are still buggy.

MDeiml commented 1 year ago

I actually managed to fix most of the things that have to do with html tags in code spans. (I just allowed "html tags in code spans", but they are not added as a node to the output). Is there still something that is not workinig?

David-Else commented 1 year ago

In the latest master of Helix I get: Screenshot from 2022-10-27 11-28-35

So it is partially fixed at the moment.

I assume the latest updates will address the following problematic text?:

`/` register by default. Use `"<char>`
MDeiml commented 1 year ago

Yes, already opened a PR to update the grammar in helix.

David-Else commented 1 year ago

Nice one, I will assume all is well and close the issue, thanks for all your hard work on this!