Cannot panel serve notebooks with %%html and html tags
I'm on the current master branch of panel and run panel serve examples/gallery/templates/material_template.ipynb and I get
(base) root@83d14de1f9b9:/workspaces/panel# panel serve examples/gallery/templates/material_template.ipynb
2021-04-17 11:02:12,409 Stripping out IPython magic %%HTML in code cell 2
2021-04-17 11:02:12,409 Stripping out IPython magic %%HTML in code cell 3
2021-04-17 11:02:12,409 Stripping out IPython magic %%HTML in code cell 4
2021-04-17 11:02:12,409 Stripping out IPython magic %%HTML in code cell 5
2021-04-17 11:02:12,409 Stripping out IPython magic %%HTML in code cell 9
2021-04-17 11:02:12,409 Stripping out IPython magic %%HTML in code cell 11
ERROR: Error loading /workspaces/panel/examples/gallery/templates/material_template.ipynb:
Invalid syntax in "material_template.ipynb" on line 42:
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
Traceback (most recent call last):
File "/opt/conda/lib/python3.8/site-packages/bokeh/application/handlers/code_runner.py", line 86, in __init__
nodes = ast.parse(source, path)
File "/opt/conda/lib/python3.8/ast.py", line 47, in parse
return compile(source, filename, mode, flags,
File "/workspaces/panel/examples/gallery/templates/material_template.ipynb", line 42
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
^
SyntaxError: invalid syntax
(base) root@83d14de1f9b9:/workspaces/panel#
Q&A
Question: Should panel serve be able to serve notebooks with %%html and html tags?
Answer: I think so. But if not then just a better error message specifying how to solve the problem would be nice.
Question: But why is %%html used in this notebook?
Answer: Panel does not support (via pn.extension or pn.config) adding something like Roboto fonts. We need to be able to add <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
I will restructure this notebook and leave a general solution for others :-)
The handling for stripping magics lives in Bokeh so this is most easily addressed at that level.