【问题标题】:code cells do not collapse after export to html with TOC使用 TOC 导出到 html 后,代码单元格不会折叠
【发布时间】:2021-09-13 09:28:05
【问题描述】:

我倾向于使用此代码和包来使代码单元可折叠,并将笔记本的输出作为 HTML 与 TOC 共享:

library(IRdisplay)

display_html(
'

<script>  
code_show=true; 
function code_toggle() {
  if (code_show){
    $(\'div.input\').hide();
  } else {
    $(\'div.input\').show();
  }
  code_show = !code_show
}  
$( document ).ready(code_toggle);
</script>
  <form action="javascript:code_toggle()">
    <input type="submit" value="Code On/Off">
 </form>

<style type="text/css">

.container { width:80% !important; }

.main-container {
  max-width: 2000px;
  margin-left: 100px;
  margin-right: 10px;
}

/*body{font-family: Lucida Sans Unicode} */

.nav>li>a {
    position: relative;
    display: block;
    padding: 10px 15px;
    color: #004F59;
}
.nav-pills>li.active>a, .nav-pills>li.active>a:hover, .nav-pills>li.active>a:focus {
    color: #ffffff;
    background-color: #004F59;
}

.list-group-item.active, .list-group-item.active:focus, .list-group-item.active:hover {
    background-color: #004F59;
}
</style>

'
)

我最近不得不切换机器/笔记本电脑,虽然这在 Jupyter 中运行时仍然有效,但导出的 HTHL + TOC 显示代码并且描绘的按钮没有响应(即不折叠代码单元)。我正在尝试隔离问题。这种行为的原因可能是什么?谢谢。

【问题讨论】:

  • 您的示例 HTML 不包含任何数据。只有脚本和样式信息。

标签: r jupyter-notebook jupyter


【解决方案1】:

解决方案是使用:

pip install nbconvert==5.6.1

而不是 Anaconda。从来没有让它与 Anaconda 一起工作,但只能与单独的 Python 一起工作。

【讨论】:

    猜你喜欢
    • 2020-01-01
    • 1970-01-01
    • 2022-10-18
    • 2020-09-15
    • 2019-11-13
    • 2014-08-02
    • 2022-11-24
    • 2018-03-25
    • 1970-01-01
    相关资源
    最近更新 更多