explosion / spacy-course

👩‍🏫 Advanced NLP with spaCy: A free online course
https://course.spacy.io
MIT License
2.31k stars 368 forks source link

JS code insdie <script> tags is not exectued #92

Open joelostblom opened 3 years ago

joelostblom commented 3 years ago

Originally reported in my comment here https://github.com/ines/course-starter-python/issues/4#issuecomment-737010614, but I realized that this is a more general issue that also affects the spacy course, not just the Python course starter. It seems that js code included in slides via <script> tags is not executed correctly in the spacy course framework. I tried in the latest version of this GitHub repo by modifying the first slideshow (chapter1_01_introduction-to-spacy.md) to include the following just under the bullet points:

<script>console.log('This does not work')</script>

Nothing is written to the console and no errors are raised either. This is not a problem with reveal.js because downloading their example slideshow and including the same code in the index.html works just fine (more elaborate examples such as vegalite plots also work fine in reveal.js).

Curiously, it seems that javascript is enabled and working fine in the spacy course slides, because <noscript> tags do not execute either and if I include the same js as part of a button, the console does correctly show log messages when this button is pressed:

<button type="button" onclick="console.log('This works')">Click me</button>

However, if the button references as function that has been defined inside <script> tags, the console throws an error that the function is not defined.

<script>
function myFunction() {
  console.log('This does not work either')
}
</script>

<button type="button" onclick="myFunction()">Click me too</button>

I thought this meant that the <script> tags were filtered out from the source file at some point, but if I highlight the text in a slide and click "View source for highlighted", I can see that they are still there, so there must be something wrong elsewhere such as in their execution.

I tried grepping this git repo for anything related to these tags or the slides, but I didn't see anything that seemed to indicate that script js code execution was disabled. I am not familiar with js so I would very much appreciate how to troubleshoot this further. Eventually, I want to use this for displaying Vegalite plots and the old workaroudn for this did not work for me, probably because vegalite has changed how the plots are displayed and the jupyter plugin has been deprecated as it is no longer needed.