Skip to content

Syntax highlighting doesn't work in code blocks in markdown #3618

Closed

Description

@mejo-

In GitLab by @theroch on Nov 10, 2022, 09:20

If we enter code blocks in collectives the syntax highlighting doesn't work:
Screenshot_2022-11-10_091802

If we open the same file via the files tab with the files text editor,
Screenshot_2022-11-10_091754

syntax highlighting works properly:
Screenshot_2022-11-10_091805

Software Versions:

  • Firefox 106.x
  • Nextcloud 24.0.7
  • Collectives 1.5.1

Activity

  1. max-nextcloud commented on Dec 29, 2022

    @max-nextcloud
    Contributor

    This is a limitation of the text app which we use for markdown editing. So I will try and move this issue into the text repo.

  2. changed the title [-]Syntax highlighting doesn't work in collectives[/-] [+]Syntax highlighting doesn't work in code blocks in markdown[/+] on Dec 29, 2022
  3. juliusknorr commented on Dec 29, 2022

    @juliusknorr
    Member

    Last time I checked a while ago (before the move to tiptap v2) this was tricky due to the fact that we'd need to preload all highlight.js syntax files that we want to support. I couldn't find a working way to avoid that, but things might have changed in the meantime.

  4. susnux commented on Dec 31, 2022

    @susnux
    Contributor

    This is something I already noticed some time ago and tried to fix, but currently it only works if you edit the file after loading the file, as the tiptap lowlight plugin is only triggered if the content changed.
    (So loading the file -> load needed highlight.js code -> edit file & trigger content changed -> tiptap refreshes the decorations).

    I do not see an easy way to do this without changing tiptap :/

  5. CWempe commented on Apr 1, 2023

    @CWempe

    I tried Collectives for the first time today, because I am looking for such a tool in my home projects.

    And I immediately stumbled upon the missing syntax highlighting.

    I understand this might be difficult.
    But please put this on the road map.

    Maybe this is even a feature that should be listet in nextcloud/collectives#482.

    It seems like almost all the other solutions do support this:

    https://confluence.atlassian.com/doc/code-block-macro-139390.html
    https://www.bookstackapp.com/blog/beta-release-v0-25-2/#code-block-updates
    https://www.notion.so/de-de/help/code-blocks
    https://extensions.xwiki.org/xwiki/bin/view/Extension/EditorTools/Syntax%20Highlighting%20Application
    https://community.coda.io/t/code-block-syntax-highlighting/1214/35 (not yet)

  6. added
    feature: formatting
    and removed on Jun 16, 2023
  7. max-nextcloud commented on Jun 16, 2023

    @max-nextcloud
    Contributor

    My understanding is that either highlight js or lowlight js come with a set of frequently used languages and then a long set of all supported languages.
    I wonder if we could limit syntax highlighting to the frequently used languages and preload them.

  8. juliusknorr commented on Jun 16, 2023

    @juliusknorr
    Member

    Yes, this seems reasonable as a easy way.

    More complex but might be nice would be to seee if we can dynamically extend the loaded languages and trigger a rerender of the code block:

    1fc013c#diff-dc0ffe297168396604403a9825d43ae7a4cae86885f947a3191c71b6f028e66bR53-R54

  9. 2 remaining items

  10. moved this from 🧭 Planning evaluation (don't pick) to 🏗️ In progress in 📝 Productivity teamon Jul 11, 2023
  11. moved this from 🏗️ In progress to 📄 To do (~10 entries) in 📝 Productivity teamon Jul 11, 2023
  12. moved this from 📄 To do (~10 entries) to 🏗️ In progress in 📝 Productivity teamon Jul 28, 2023
  13. added 2 commits that reference this issue on Jul 28, 2023
    85399cc
    f1a0fea
  14. moved this from 🏗️ In progress to ☑️ Done in 📝 Productivity teamon Jul 28, 2023
  15. added 2 commits that reference this issue on Jul 28, 2023
    c5294fe
    7587260
  16. added a commit that references this issue on Jul 28, 2023
    edd4175
  17. self-assigned this
    on Jul 28, 2023
  18. theroch commented on Aug 11, 2023

    @theroch
    Contributor

    I think the fix is only available for Nextcloud version 26 and above, right?
    In Nextcloud 25.0.10 with Collectives 2.7.0 the issue still exists.

  19. max-nextcloud commented on Aug 11, 2023

    @max-nextcloud
    Contributor

    Exactly. It's available in 26.0.5 and 27.0.2.

  20. theroch commented on Sep 7, 2023

    @theroch
    Contributor

    We've tested it now on 27.0.2. The syntax highlighting is working in edit mode but in the view mode it doesn't.
    Should I open another issue or does it belong to this issue?

  21. max-nextcloud commented on Sep 7, 2023

    @max-nextcloud
    Contributor

    @theroch It's fixed in text but we need to release a new version of collectives with that uses the new version of text for view mode.
    We're working on it and the fix will automatically land in collectives then.
    So please open a new issue in collectives to document this is still missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

1. to developenhancementfeature: formattingformat: markdownjavascript

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions