forgejo-federation/services
mrsdizzie 9542b7317d
Fix Syntax highlight for token change in added/deleted code (#12238)
* Fix Syntax highlight for token change in added/deleted code

For diffs we first syntax highlight the before and after line then use a 3rd party diff library to find the difference in them and create a substring based on that, which we then highlight a 2nd time to show the specific difference within a line that has changed. In a specific case if the diffrence also changes the chroma class it will split in the middle of the attr and cause broken HTML:

```
<span class="nx">oldtext<span>
<span class="k">var newtext<span>
```

Will then split on

```
<span class="
```

Where the difference starts, and produce something broken like:

```
<span class="<span class="removed-code">nx"oldtext</span></span

```

Fix that by detecting when it happens and putting the HTML back together properly before highlighting the added/deleted code.

Fixes #12235

* fix lint

* apply fix to all diff sections. Also handle case where insert/remove starts with a closing span

* Add a test for this new code

* remove comment

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-07-16 16:58:54 +03:00
..
comments Refactor pull request review (#8954) 2019-11-14 10:57:36 +08:00
externalaccount Allow externalID to be UUID (#8551) 2019-10-17 10:06:28 +08:00
gitdiff Fix Syntax highlight for token change in added/deleted code (#12238) 2020-07-16 16:58:54 +03:00
issue Fix ref links in issue overviews for tags (#8742) 2020-05-14 18:55:43 -04:00
mailer Add push commits history comment on PR time-line (#11167) 2020-05-20 09:47:24 -03:00
mirror Update the wiki repository remote origin while update the mirror repository's Clone From URL (#12053) 2020-07-05 22:08:32 -04:00
pull Update CommitsAhead CommitsBehind on Pull BaseBranch Change too (#11912) 2020-06-16 12:52:33 -05:00
release When using API CreateRelease set created_unix to the tag commit time (#11218) 2020-04-30 14:10:42 +01:00
repository API endpoint for repo transfer (#9947) 2020-01-31 15:49:04 +00:00
wiki Handle push rejection in branch and upload (#10854) 2020-03-28 01:13:18 -03:00