Articles

rst2wiki with math support

In howto on Jul 3, 2012 by theoryl Tagged: , , , , , ,

Another post about reStructuredText: can you convert reStructuredText into Wiki format? I found in Docutils sandbox a tool: rst2wiki. It currently supports conversion to TWiki and Atlassian Confluence. rst2wiki is available through SVN (web-access)

In Docutils >= 0.8, there is “math” support; on the other hand, TWiki can display LaTeX equations if MathModePlugin is installed and set up properly. The syntax is

<latex [attr="value"]* > formula </latex>

In order to use rst2wiki with math support, we will modify wiki.py. In class WikiTranslator, add:

    ###
    # Start Math
    #
    def visit_math(self, node):
        if self.math_start:
            self.body.append(self.math_start)

    def depart_math(self, node):
        if self.math_end:
            self.body.append(self.math_end)
    #
    # End Math
    ###

In class TWikiTranslator, add:

        self.math_start = '<latex>'
        self.math_end = '</latex>'

Done :)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: