SaswatPadhi / pseudocode.js

Beautiful pseudocode for the Web
https://saswatpadhi.github.io/pseudocode.js
MIT License
221 stars 33 forks source link

MathJax 4.0 #44

Closed sebsciarra closed 1 year ago

sebsciarra commented 1 year ago

I am trying to use pseudocode.js with MathJax 4.0. I have followed all the four steps listed in the ReadMe file, but cannot seem to get it to work with MathJax 4.0. Here is how I call MathJax 4.0:

<script src="https://cdn.jsdelivr.net/npm/mathjax@4.0.0-alpha.1/es5/tex-mml-chtml.js"
        integrity="9df6fbc821287c8717485c417ee18bde3f94a30d18d2dec88c29200806c7dabe"
        crossorigin="anonymous" referrerpolicy="no-referrer">
</script>
SaswatPadhi commented 1 year ago

Hi, thanks for the report.

I was able to test on my machine and indeed MathJax 4.0 back end doesn't seem compatible. I am looking into it.

SaswatPadhi commented 1 year ago

Hi,

I pushed some changes to make pseudocode work with MathJax 4.x as well. You can see a working sample page here: https://saswat.padhi.me/pseudocode.js/mathjax-v4-samples.html.

It's not the most elegant solution, and I haven't released a new version, but could you try the docs/pseudocode.js file and let me know if you notice any issues?

I saw your thread on the MathJax repo as well. Thanks for starting the discussion there. I'll comment on that thread to see if the MathJax devs have some suggestions.

sebsciarra commented 1 year ago

Ok, I have tried two attempts with no success.

First attempt: In my<head> file, I used

<script src="https://cdn.jsdelivr.net/npm/mathjax@4.0.0-beta.3/tex-chtml.js"
              integrity="sha256-ljPODBK7Jf/VfUrVqec63xzZbysEmwB9Ab20TWRMQRU="
              crossorigin="anonymous">

      </script>
     <script src="{{ "js/pseudocode.js" | relURL }}"></script>

which yielded a semi-rendered version of the pseudocode (see attached image)

semi-rendered

Second attempt: I loaded the pseudocode.js from the directory, but had no success.

  <script src="https://cdn.jsdelivr.net/npm/mathjax@4.0.0-beta.3/tex-chtml.js"
          integrity="sha256-ljPODBK7Jf/VfUrVqec63xzZbysEmwB9Ab20TWRMQRU="
          crossorigin="anonymous">

  </script>
     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pseudocode@2.4.1/build/pseudocode.min.css">
<script src="https://cdn.jsdelivr.net/npm/pseudocode@2.4.1/build/pseudocode.min.js">
</script>

My only success has been using

 <script src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-chtml-full.js"
        integrity="sha256-kbAFUDxdHwlYv01zraGjvjNZayxKtdoiJ38bDTFJtaQ="
        crossorigin="anonymous">
</script>
     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pseudocode@2.4.1/build/pseudocode.min.css">
<script src="https://cdn.jsdelivr.net/npm/pseudocode@2.4.1/build/pseudocode.min.js">
</script>
SaswatPadhi commented 1 year ago

Hi,

Thanks for testing.

The first attempt should work (that's what the v4 samples does), but it's asynchronous so you'll have to wait (a few seconds) for the algorithm to fully render.

Can you also let me know if this page (https://saswat.padhi.me/pseudocode.js/mathjax-v4-samples.html) fully renders within a few seconds on your machine?

The second attempt shouldn't work. It's usually the old pseudocode.js without MathJax 4.0 support.

The third attempt uses MathJax 3 and should work.

sebsciarra commented 1 year ago

Hmm ok! Made a couple of fixes and you are correct. Got the first method to work! And yes the link works perfectly for me! Appreciate the fast responses!