jupyterlab-contrib / rise

RISE: "Live" Reveal.js JupyterLab Slideshow Extension
BSD 3-Clause "New" or "Revised" License
182 stars 18 forks source link

Fixes Syntax Highlighting #19

Closed AnotherCodeArtist closed 1 year ago

AnotherCodeArtist commented 1 year ago

Hi @fcollonval!

Thanks for integrating my latest PR so quickly and to come up with a new release immediately after. I upgraded my images and ran into another problem (at least with Golang/Gophernotes notebooks). All code was there, but some of the code cells weren't syntax highlighted. Thus, I started to dig into the problem. First thought was that it's possibly a problem with codemirror and its integration into jupyterlab itself, which caused me to consistently upgrade all jupyterhub/* dependencies to the latest 3.x version (3.6.1.). But no success. Looks like codemirror uses the same promise to kick-in. which apparently leads to a sort of race-condition with initializeReveal, leaving some of the cells raw text (unless clicking into them). Best solution I could find is to add some extra delay (500ms currently) before calling initializeReveal, which fixes the issue.

      notebookPanel.context.ready.then(() => {
        setTimeout(() => {
          initializeReveal(null, {
            name: 'dirty',
            newValue: notebookPanel.model?.dirty ?? true,
            oldValue: true
          })
        }, 500);
      });

It's definitely not the smartest approach, but I couldn't find another callback/trigger that would indicate the end of syntax highlighting.

It would be cool if you could again publish a new release soon!

github-actions[bot] commented 1 year ago

Binder :point_left: Launch a Binder on branch AnotherCodeArtist/rise/main

fcollonval commented 1 year ago

Thanks @AnotherCodeArtist for your contribution

Could you try loading the CodeMirror mode ahead of initializeReveal?

You can achieve this with something like:

import { Mode } from '@jupyterlab/codemirror';

// ...
await Mode.ensure(notebookPanel.content.codeMimetype);
initializeReveal(...)

Could you also revert all changes except that one?

AnotherCodeArtist commented 1 year ago

Hi Frédéric @fcollonval!

Thank's for your support! Works like a charm now. Although, I ended up with eslint using internally a different, conflicting version of prettier. Thus, what was fixed by prettier was seen as an error by eslint and vice versa. Eventually I upgraded both to the latest version, which fixed this problem.

AnotherCodeArtist commented 1 year ago

Hi @fcollonval!

Is there any chance to release this new version over the weekend? I desparately need a working version by Monday afternoon.