gitextensions / ICSharpCode.TextEditor

ICSharpCode.TextEditor for WinForms
14 stars 22 forks source link

Markdown preview in diff pane incorrectly renders italics for sections containing underscores #35

Closed shirayuki closed 11 months ago

shirayuki commented 11 months ago

Environment

    Microsoft.WindowsDesktop.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
    Microsoft.WindowsDesktop.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Issue description

When displaying the source of a markdown file in the Diff pane, sections enclosed in underscores or starting with underscores are incorrectly formatted in italics.

Example:

# sample database

## sample_table

| Column name            | Data type         |
|------------------------|-------------------|
| first_column           | INTEGER           |
| second_third_column    | INTEGER           |

image

Steps to reproduce

  1. Create a markdown file that includes underscores.
  2. Show the source code in the Diff pane.

Did this work in previous version of GitExtensions?

No response

Diagnostics

No response

gerhardol commented 11 months ago

The style handler in the FileViewer is very limited, it cannot check the character before. A complete rewrite or replace of the FileViewer wold be a big change. The style is set in Externals\ICSharpCode.TextEditor\Project\Resources\Markdown.xshd

The "solution" would be to handle the preview of italics as for bold: disable

pmiossec commented 11 months ago

The support of markdown is know to be brittle. The idea was to propose something good enough to help the user even if some limitation are known due to how the undocumented syntax highlighting is working (or at least of my --lack of-- knowledge of it when I have added the support of markdown).

I don't see something in https://github.com/gitextensions/ICSharpCode.TextEditor/blob/master/Project/Resources/Mode.xsd that allows us to handle it cleverly.

The only solution is to disable the rule but I'm not sure I want that...