【问题标题】:In exported Jupyter Notebooks, how do I disable the ¶?在导出的 Jupyter Notebooks 中,如何禁用 ¶?
【发布时间】:2016-09-15 18:36:25
【问题描述】:

当我将笔记本导出为 html 时,我的标题末尾有一个 ¶(pilcrow);如何关闭它?

这是我正在使用的示例命令:

jupyter nbconvert --to html --template basic Untitled.ipynb

笔记本只包含一个带有降价标题和文本的单元格:

# Here I am

Rock you like a hurricane

【问题讨论】:

  • 我不确定是否有办法禁用此功能。但它存在有一个很好的理由:它为用户提供了一种链接到特定标题的简单方法。为什么要禁用它?
  • 我正在从笔记本中生成数百个静态报告,而 pilcrow 看起来很奇怪。我的用户无论如何都无法链接到 html,它是嵌入的。
  • 目前没有简单的方法来禁用它,但如果你想破解你的本地代码副本,添加该 pilcrow 的行是here
  • 感谢您的指点。看起来它将修复遗留标题;你认为它还会修复 Markdown 标题吗?
  • 我收回那句话,我猜MarkdownWithMath 在那里打电话给IPythonRenderer

标签: markdown jupyter-notebook nbconvert


【解决方案1】:

我也有这个问题。我的解决方法是意识到 pilcrow 在 html 中有自己的类,这与它后面的标题不同,并将以下内容添加到 css 以使 pilcrow 的字体大小为 0,从而从渲染中删除 pilcrow页面。

.anchor-link{
    font-size: 0;
}

您还可以使文本颜色与背景相同,或进行其他一些操作以使 Pilcrow 有效地消失。

【讨论】:

  • 我不能在 HTML 电子邮件中使用 css :(
【解决方案2】:

现在支持作为配置选项:

c.HTMLExporter.anchor_link_text = '' # disable pilcrow, requires nbconvert >= 5.2

旧:

我可以通过修补 markdown 渲染器来关闭 pilcrows:

import mistune
import nbconvert
nbconvert.filters.markdown_mistune.IPythonRenderer.header = mistune.Renderer.header

不过,这看起来很 hacky。

【讨论】:

    猜你喜欢
    • 2019-06-22
    • 2019-12-04
    • 2019-04-11
    • 1970-01-01
    • 1970-01-01
    • 2020-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多