rtfpessoa / diff2html

Pretty diff to html javascript library (diff2html)
https://diff2html.xyz
MIT License
2.79k stars 272 forks source link

Problems with multiline code blocks highlighted incorrectly #526

Closed aivarsi closed 2 months ago

aivarsi commented 4 months ago

Describe the problem:

When code contains multi-line blocks, e.g. multi-line comments, only the first line is highlighted correctly but the rest are not.

Steps to reproduce:

Using your diff2html Online Demo, open any pull that contains multi-line comments e.g. https://diff2html.xyz/demo.html?matching=none&matchWordsThreshold=0.25&maxLineLengthHighlight=10000&diffStyle=word&colorScheme=light&renderNothingWhenEmpty=0&matchingMaxComparisons=2500&maxLineSizeInBlockForComparison=200&outputFormat=line-by-line&drawFileList=1&synchronisedScroll=1&highlight=1&fileListToggle=1&fileListStartVisible=0&highlightLanguages=[object%20Map]&smartSelection=1&fileContentToggle=1&stickyFileHeaders=1&diff=https://github.com/Automattic/themes/pull/7664

There is this comment block:

/**
 * Title: Hidden No Results Content
 * Slug: lettre/hidden-no-results-content
 * Inserter: no
 */

We can observe that the first line is highlighted as comment but the others are not.

rtfpessoa commented 2 months ago

The highlight of the code is mostly a best effort since we only have parts of the code it is hard to get a precise without the full file. If you have suggestions on how to fix it I am open to hear it, but for now this is the best we can do.