【问题标题】:Liquid::SyntaxError with Plotly in Markdown files using JekyllLiquid::SyntaxError with Plotly in Markdown files using Jekyll
【发布时间】:2021-06-21 03:35:38
【问题描述】:

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

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

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

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

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

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

【问题讨论】:

    标签: plotly markdown jupyter jekyll liquid


    【解决方案1】:

    您发布的 JavaScript 文件似乎存在许多语法不一致。提到的与 Liquid 模板的输出标签 {{ ... }} 冲突。

    问题来了:

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

    不应该有双括号:

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

    【讨论】:

    • 感谢您的反馈。我修复了您在此处提到的语法不一致(删除了额外的大括号),但在尝试在 Jekyll 中构建时遇到了其他问题。我将假设这与在语句init_notebook_mode() 中导入的Plotly.js 库有关。将此问题提交给 Plotly 开发团队,希望我不必将每个图表导出为 HTML,然后从头开始创建我的笔记本 Markdown 文件。
    猜你喜欢
    • 2016-11-19
    • 2017-04-07
    • 2022-12-26
    • 2020-05-17
    • 2013-03-08
    • 2020-10-10
    • 2015-02-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多