convert ipython notebook to mediawiki

≡放荡痞女 提交于 2019-12-22 18:02:09

问题


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

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

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?


回答1:


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 %}

So mediawiki will probably be

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

One just need to write the all template.

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.



来源:https://stackoverflow.com/questions/19082746/convert-ipython-notebook-to-mediawiki

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!