将ipython笔记本转换为mediawiki [英] convert ipython notebook to mediawiki

查看:115
本文介绍了将ipython笔记本转换为mediawiki的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将ipython笔记本转换为mediawiki标记。我有两个想法如何做到这一点:

I would like to convert an ipython notebook to mediawiki markup. I had two ideas how to do that:


  1. 自定义 nbconvert的导出工具。

  2. 首先导出到LaTeX,然后使用 pandoc 将其转换为mediawiki标记。

  1. Customize an export for the nbconvert tool.
  2. Export to LaTeX first and then use pandoc to convert it to mediawiki markup.

我在第一个选项上找不到任何内容。第二个选项的问题是LaTeX输出放入了许多自定义命令,这些命令未转换为< source lang ='python'> ...< / source> 正确标记。有人有个好主意吗?

I couldn't find anything on the first option. The problem for the second option is that LaTeX output puts in a lot of custom commands which are not converted into <source lang='python'> ... </source> tags correctly. Does anybody have a good idea?

推荐答案

你可以在 issue 4058 nbconvert:Wikipedia(mediawiki)输出 。如果您想学习如何为nbconvert编写导出器,我们很乐意为您提供指导。

you can probably pitch-in in issue 4058 nbconvert: Wikipedia (mediawiki) output. We'll be happy to guide you if you want to learn how to write an exporter for nbconvert.

您基本上需要编写模板。
例如,标记中的标题生成为:

You will basically need to write template. For example, heading in markdow are generated with :

{% block headingcell scoped %}
{{ '#' * cell.level }} {{ cell.source | replace('\n', ' ') }}
{% endblock headingcell %}

所以mediawiki可能是

So mediawiki will probably be

{% block headingcell scoped %}
{{ '=' * cell.level }}{{ cell.source | replace('\n', ' ') }}{{ '=' * cell.level }}
{% endblock headingcell %}

只需编写所有模板。

我们当然需要编写更多关于如何扩展nbconvert的文档如果您想提供帮助,我们也乐意为您提供帮助。

We of course need to write more docs on how to extend nbconvert if you want to help with that, we'll happy to help too.

这篇关于将ipython笔记本转换为mediawiki的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆