首页 > 解决方案 > Liquid::SyntaxError with Plotly in Markdown files using Jekyll

问题描述

尝试将.ipynb笔记本转换为包含 Plotly 图表的 Markdown,以便在 Jekyll 站点(托管在 GitHub Pages 上)中使用。我遇到了这个错误:

Liquid Exception: Liquid syntax error (line 134): Variable '{{ x.observe(notebookContainer, {childList: true}' was not properly terminated with regexp: /\}\}/ bundler: failed to load command: jekyll

使用这个简单的笔记本来复制这个问题,链接在这里。Markdown 转换文件在这里

.md我尝试以转换格式(和)从 Jupyter 下载笔记本,.html但遇到了同样的错误。当文件在我的项目目录中时,程序在启动时冻结,也无法在 Xcode 中打开 Markdown 文件。

非常感谢您对此问题的任何帮助。

编辑:这里提到的解决方法是删除init_notebook_mode()pio.renderers.default = 'jupyterlab'. 也避免直接在笔记本中使用pio.write_html()而不是渲染 Plotly。导出到.md,添加 YAML 前端,然后调用{% include figure_name.html %}.

标签: plotlymarkdownjupyterjekyllliquid

解决方案


您发布的 JavaScript 文件看起来有许多语法不一致。提到的与 Liquid 模板的 output tag 冲突{{ ... }}

这是问题:

if (notebookContainer) {{
  x.observe(notebookContainer, {childList: true});
}}

不应该有双括号:

if (notebookContainer) {
  x.observe(notebookContainer, {childList: true});
}

推荐阅读