问题
I would like to convert an ipython notebook to mediawiki markup. I had two ideas how to do that:
- Customize an export for the
nbconvert
tool. - 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