Embedded formatted code snippets (e.g. Python or MathML)

Is it possible to display a Python code snippet or MathML? I was trying the Code Widget from the Bric Library. But it isn’t working.

Do any of you have any ideas or can you help me? Thank you very much.

I found this solution for a python code snippet:

Has anybody an idea? Thank you very much.

Try switching off preview in app. Checkbox in the sidebar when code snippet is selected.

Thank you for help @Norm.
I was trying your suggestion. But it’s the same, with the Preview in Browser it works fine but not with my Webspace.

In the meantime I found a Online LaTeX Equation Editor - create, integrate and download. But it only works if I leave the preview checkbox on for the Code Widget.

1 Like

If I export a HTML-File from my Jupyter Notebook with my Python code and upload it to my server it works very well (with every line break and the same format).

But if I copy the full code from the HTML-File und paste it in a Code Widget. It’s only working in Preview in Browser (⌥⌘B). If I export my project and upload it to my Server the line break is missing.

Here is the Blocs-File, HTML-File from Jupyter:
data.zip (245.0 KB)

Maybe someone can help. Thank you very much.

Okay, I was trying this one: https://highlightjs.org - data.bloc (719.4 KB)
But this doesn’t work either.

It seems as if Blocs uses a global CSS, which partially overrides the formatting of the code widget. I have no idea what I need to do, to change or solve this.

My understanding from your original file is that the Code Widget should contain plain HTML while yours is packed with the CSS styling which in turn should be either added as an extra css file or copied into the Page settings under add code (Head section).


try the following.

  1. Open the HTML widget.
  2. Delete the content.
  3. switch the widget to not preview in app.
  4. paste the code back into the widget.

Simply switching to none preview mode may not fix the issue, it be require the code re-pasted in after the widget is set to not preview in app. This in theory should protect the code.

Thank you @MDS and @Norm for your help. At the moment I try @Norm suggestion but it isn’t working. I was following your route and did it in fresh Blocs-Project. It’s the same, the line break isn’t working.

In the next step I will try @MDS suggestion :crossed_fingers:

Also switch off minifying of HTML.

@Norm you are awsome. Thank you very much. This is the solution for me ==> switch off minifying of HTML :+1: