Skip to content

Multinline comments in the start break syntax highlighting #6057

@oscarlofwenhamn

Description

@oscarlofwenhamn
Contributor
  • Gitea version (or commit ref): 1.7.1
  • Git version: n/a
  • Operating system: Windows 10
  • Database (use [x]):
    • PostgreSQL
  • Can you reproduce the bug at https://try.gitea.io:
  • Log gist: n/a

Description

When starting a file with a multiline comment or sometimes multiple lines of comments, syntax highlighting breaks (at least for .ps1 files).

For example, starting a file with one of the following works fine:

# Foo
---
<# Bar #>
---
# Bleh
#

This, however, breaks it:

<# Foo
#>
---
## Bar
##

Sample files in repo

Screenshots

image

image

image

Activity

oscarlofwenhamn

oscarlofwenhamn commented on Feb 14, 2019

@oscarlofwenhamn
ContributorAuthor

Another example can be found in the example posted in #6064.

zeripath

zeripath commented on Feb 19, 2019

@zeripath
Contributor

Hi!

Is this still an issue on try.gitea.io?

The revision that fixed #6064 probably fixed this.

oscarlofwenhamn

oscarlofwenhamn commented on Feb 19, 2019

@oscarlofwenhamn
ContributorAuthor

Hi,
Yes, this problem remains (see my repo for an example: https://try.gitea.io/foobarbleh/foo).

silverwind

silverwind commented on Feb 19, 2019

@silverwind
Member

I suspect a highlight.js issue here.

oscarlofwenhamn

oscarlofwenhamn commented on Feb 20, 2019

@oscarlofwenhamn
ContributorAuthor

Is Gitea running the latest version? Could this be something to report to the highlight.js team?

silverwind

silverwind commented on Feb 20, 2019

@silverwind
Member

highlight.js is 9.11.0, latest is 9.14.0.

It would help if you can showcase the issue in a fiddle like this, using the latest version.

oscarlofwenhamn

oscarlofwenhamn commented on Feb 21, 2019

@oscarlofwenhamn
ContributorAuthor

I'm new to using fiddle, but I've given it a shot here. (I'm guessing there's no way of embedding fiddles on GitHub?)

One of the variants that are broken on Gitea works in the fiddle, but the second example remains broken. Let me know if there are any modifications or corrections that should be made to the fiddle and I'll sort it out.


Fiddle output screenshot:
image

oscarlofwenhamn

oscarlofwenhamn commented on Feb 27, 2019

@oscarlofwenhamn
ContributorAuthor

If this isn't a priority issue for the general group, could anyone point me towards where (if possible) I could define what version of Highlight.js my instance should run? It would be nice to have this in upstream, but I would gladly sort out a local fix if this is not a priority issue.

jolheiser

jolheiser commented on Feb 27, 2019

@jolheiser
Member

A temporary local workaround could be to use a custom footer template that instead gets highlight.js from {{AppSubUrl}}/js/highlight.js and then add the new version of highlight.js to your custom/public/js folder.
Docs for customizing templates

silverwind

silverwind commented on Feb 27, 2019

@silverwind
Member

Updated fiddle with 9.15.6: https://jsfiddle.net/vk3j2gLd/3/

All three cases look alright, correct?

oscarlofwenhamn

oscarlofwenhamn commented on Feb 28, 2019

@oscarlofwenhamn
ContributorAuthor

Updated fiddle with 9.15.6: https://jsfiddle.net/vk3j2gLd/3/

All three cases look alright, correct?

Yes, this looks great!

I'm gonna test it out with a local workaround, thanks for the suggestion @jolheiser. I'll get it done right away and post an update here, and if it works I'll close this issue and open a new one for updating highligt.js, if no one objects.

silverwind

silverwind commented on Feb 28, 2019

@silverwind
Member

Once you confirm it works with in Gitea with newer highlight.js, I can raise a PR to update it. You want to use these resources:

https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/default.min.css
https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/highlight.min.js
oscarlofwenhamn

oscarlofwenhamn commented on Feb 28, 2019

@oscarlofwenhamn
ContributorAuthor

I can confirm that the variants listed in the fiddle all work with newer highlight.js, using the resources you've provided.


I did, however, notice another breaking variant. If I write three or more lines with two or more #'s, it still breaks, looking like the third line of #'s gets interpreted as something very particular as it gets uniquely highlighted.

image

This still is an improvement, but it is unfortunate as the user who raised the issue has a habit of tagging his codes with exactly that: opening with several lines of several #'s ... I will just have to ask him not to.

7 remaining items

added
issue/confirmedIssue has been reviewed and confirmed to be present or accepted to be implemented
on Jun 16, 2019
oscarlofwenhamn

oscarlofwenhamn commented on Jul 17, 2019

@oscarlofwenhamn
ContributorAuthor

Sorry, mistakenly closed the issue.

locked and limited conversation to collaborators on Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue/confirmedIssue has been reviewed and confirmed to be present or accepted to be implementedtype/bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @lunny@silverwind@zeripath@jolheiser@oscarlofwenhamn

      Issue actions

        Multinline comments in the start break syntax highlighting · Issue #6057 · go-gitea/gitea