gitextensions / ICSharpCode.TextEditor

ICSharpCode.TextEditor for WinForms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

shirayuki opened this issue · comments

Environment

  • Git Extensions 4.2.1.17611
  • Build b0c0b284876b63c52c77195ada82a85bfadbb083
  • Git 2.43.0.windows.1
  • Microsoft Windows NT 10.0.22631.0
  • .NET 6.0.25
  • DPI 96dpi (no scaling)
  • Portable: False
  • Microsoft.WindowsDesktop.App Versions
    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

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

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...