Pandoc Jupyter 过滤器允许/阻止代码块

问题描述 投票:0回答:1

我(大部分成功)将 Jupyter 转换为 LaTex。

我可以使用此 Lua 过滤器允许/阻止 Jupyter 代码块出现在 LaTex 中:

function Div(el)
  if el.classes:includes("code") then
    if el.content[1].t == "CodeBlock" then
      el.content:remove(1)
    end
  end
  return el
end

现在正在寻找 Lua 过滤器或其他解决方案来仅阻止那些设置为不显示的 Jupyter 代码块。你能帮助我吗? 或者,如何使用过滤器来仅阻止包含特定文本的 Jupyter 代码块?

非常感谢。

jupyter-notebook lua latex pandoc
1个回答
0
投票

啊,解决方案如下:

function Div(el)
  if el.classes:includes("code") then
    if el.attributes['hide_input'] == "true" then
      if el.content[1].t == "CodeBlock" then
        el.content:remove(1)
      end
    end
  end
  return el
end
© www.soinside.com 2019 - 2024. All rights reserved.