Skip to content

Syntax highlighting does not work in 1.9rc2 #7559

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
2 of 7 tasks
fincham opened this issue Jul 22, 2019 · 6 comments · Fixed by #7617
Closed
2 of 7 tasks

Syntax highlighting does not work in 1.9rc2 #7559

fincham opened this issue Jul 22, 2019 · 6 comments · Fixed by #7617
Labels
Milestone

Comments

@fincham
Copy link

fincham commented Jul 22, 2019

  • Gitea version (or commit ref): 1.9.0+rc2-1-ga29e667ef built with GNU Make 4.1, go1.12.7 : bindata,
    sqlite, sqlite_unlock_notify
  • Git version: 2.17.1
  • Operating system: Ubuntu Bionic x86_64
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant

Description

In this release the code highlighting does not activate when viewing files, even though index.js seems to call it. The <code> element ends up with an empty class string and no highlighting occurs.

Downgrading to 1.8.3 fixes the problem.

@silverwind
Copy link
Member

I can see this on try.gitea.io here. I suspect it might be related to the recent jQuery update on the 1.9 branch.

@silverwind
Copy link
Member

Seems like some kind of race condition with the highlight. If I do a no-cache reload in Firefox (CTRL-Shift-R), it highlights correctly.

@fincham
Copy link
Author

fincham commented Jul 22, 2019

Thanks for checking that. try.gitea.io was too slow / broken for me to find any actual files yesterday to confirm :(

@fincham fincham changed the title Highlighting does not activate in 1.9rc2 Syntax highlighting does not work in 1.9rc2 Jul 22, 2019
@lunny lunny added the type/bug label Jul 23, 2019
@lunny lunny added this to the 1.9.0 milestone Jul 23, 2019
@archtaurus
Copy link

archtaurus commented Jul 24, 2019

i put these in custom/templates/custom/header.tmpl to solve this problem for now ...

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.8/styles/github.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.8/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>

silverwind added a commit to silverwind/gitea that referenced this issue Jul 25, 2019
Previously hljs was initialized via a function that relies on the
DOMContentLoaded event, registerd after jQuery's 'ready' event. I assume
that with the recent jQuery update, DOMContentLoaded may not be
guaranteed to fire after 'ready'. Fixed this via vanilla JS initalization.

Fixes: go-gitea#7559
zeripath pushed a commit that referenced this issue Jul 25, 2019
* Fix syntax highlight initialization

Previously hljs was initialized via a function that relies on the
DOMContentLoaded event, registerd after jQuery's 'ready' event. I assume
that with the recent jQuery update, DOMContentLoaded may not be
guaranteed to fire after 'ready'. Fixed this via vanilla JS initalization.

Fixes: #7559

* semicolon
silverwind added a commit to silverwind/gitea that referenced this issue Jul 26, 2019
* Fix syntax highlight initialization

Previously hljs was initialized via a function that relies on the
DOMContentLoaded event, registerd after jQuery's 'ready' event. I assume
that with the recent jQuery update, DOMContentLoaded may not be
guaranteed to fire after 'ready'. Fixed this via vanilla JS initalization.

Fixes: go-gitea#7559

* semicolon
zeripath pushed a commit that referenced this issue Jul 26, 2019
* Fix syntax highlight initialization

Previously hljs was initialized via a function that relies on the
DOMContentLoaded event, registerd after jQuery's 'ready' event. I assume
that with the recent jQuery update, DOMContentLoaded may not be
guaranteed to fire after 'ready'. Fixed this via vanilla JS initalization.

Fixes: #7559

* semicolon
@fincham
Copy link
Author

fincham commented Sep 11, 2019

Hi there,

I'm now on 1.9.3 and this issue is still present, highlighting only activates maybe ~ 50% of the time on page loads :(

@lunny
Copy link
Member

lunny commented Sep 12, 2019

Could you try to clean the cache of browser?

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants