Top Menu

Jump to content
Home
    Modules
      • Projects
      • Activity
      • Work packages
      • Gantt charts
      • Calendars
      • Team planners
      • Boards
      • News
    • Getting started
    • Introduction video
      Welcome to OpenProject Community
      Get a quick overview of project management and team collaboration with OpenProject. You can restart this video from the help menu.

    • Help and support
    • Upgrade to Enterprise edition
    • User guides
    • Videos
    • Shortcuts
    • Community forum
    • Enterprise support

    • Additional resources
    • Data privacy and security policy
    • Digital accessibility (DE)
    • OpenProject website
    • Security alerts / Newsletter
    • OpenProject blog
    • Release notes
    • Report a bug
    • Development roadmap
    • Add and edit translations
    • API documentation
  • Sign in
      Forgot your password?

      or sign in with your existing account

      Google

Side Menu

  • Overview
  • Activity
    Activity
  • Roadmap
  • Work packages
    Work packages
  • Gantt charts
    Gantt charts
  • Calendars
    Calendars
  • Team planners
    Team planners
  • Boards
    Boards
  • News
  • Forums

Content

General discussion
  1. OpenProject
  2. Forums
  3. General discussion
  4. Code snippet formatting not working

Code snippet formatting not working

Added by Jason Culligan over 5 years ago

If I use the code snippet and add say Python and I change the format type by manually typing 'python', the formatting in the editor autoformats.  But when I save and review it the formatting it gone and it's just all black text.  No python formatting.

Questions:

  1. How to fix this?
  2. What formatting types can be entered?
  3. Why isn't there a selector to show which formats are available instead of assuming the end user knows exactly which languages are supported and what exactly to type?
  4. Am I doing it all wrong?

Replies (1)

RE: Code snippet formatting not working - Added by Oliver Günther over 5 years ago

Hi Jason,

this is due to CKEditor not yet providing a WYSIWYG code block. We added a custom widget that is based on codemirror that allows dynamically loading syntax and highlight modes from these values here: https://github.com/codemirror/CodeMirror/tree/master/mode

Highlight will thus only work within the codemirror editor (double click the widget in CKEditor to open the editor modal again), and when you save the page. This widget is only meant as a workaround until CKEditor provides their own code block implementation: https://github.com/ckeditor/ckeditor5/issues/436

There is of course lots of room for improvements, it's not our topmost priority at the moment since hopefully, CKEditor5 will provide the correct solution.

  • The syntax highlighting mode name must be guessed or known. This is the same as writing plain Markdown, where you highlighted your blocks in Markdown with a given marker ```ruby\n....
  • CodeMirror has its own styles and thus the highlighting rendered from the backend differs (its using rouge syntax highlighter)
  • Ideally we would always render the open WYSIWYG editor that highlights its own code blocks

Best,

Oliver

  • (1 - 1/1)
Loading...