A Multiformat
Document Workflow
  using Docutils
            Matthew Leingang
            New York University

 MAA Session on Publishing Math on the Web
             San Francisco, CA
             January 15, 2010
Multiformat
Multiformat


 ∞
 1       π2
      2
        =
n=1
    n     6
Multiformat

                          ∞
                          1       π2
                               2
                                 =
                         n=1
                             n     6

 ∞
 1       π2
      2
        =
n=1
    n     6
HTML
HTML
Take a Picture?
(From Wikipedia)

MathML?
Firefox
Google Chrome
LaTeX
A third way?
Docutils
                                    ∞
                                    1       π2
http://docutils.sourceforge.net/       n 2
                                           =
                                             6
                                   n=1
Docutils has many products


Python
 Code
Docutils has many products


Python
         ReST
 Code
Docutils has many products

                XHTML

Python
         ReST
 Code
Docutils has many products

                XHTML

Python
         ReST
 Code
                LaTeX
Docutils has many products

                XHTML

Python
         ReST
 Code
                LaTeX



                 PDF
Docutils has many products

                 XHTML

Python
         ReST
 Code
                 LaTeX



         troff
                  PDF
Docutils has many products

                 XHTML

Python
         ReST
 Code
                 LaTeX   PDF



         troff
                  PDF
Docutils has many products

                 XHTML   XHTML

Python
         ReST
 Code
                 LaTeX    PDF



         troff
                  PDF
Docutils has many products

              XHTML   XHTML

       ReST
              LaTeX    PDF
ReStuctured Text is human-
  and machine-readable
ReStuctured Text is human-
  and machine-readable
           San Francisco is emph{beautiful}
LAT   EX   in January!
ReStuctured Text is human-
  and machine-readable
           San Francisco is emph{beautiful}
LAT   EX   in January!




           San Francisco is
 HTML      strongbeautiful/strong in
           January!
ReStuctured Text is human-
  and machine-readable
           San Francisco is emph{beautiful}
LAT   EX   in January!


           San Francisco is *beautiful* in
 ReST      January!


           San Francisco is
 HTML      strongbeautiful/strong in
           January!
Sections
           Title
           !!!!!

           Introduction
           ============

           Math on the Web
           ===============

           XHTML
           -----

           XHTML is an application ...
Sections
             Title
             !!!!!

             Introduction
             ============
Configured
 by your     Math on the Web
  usage      ===============

             XHTML
             -----

             XHTML is an application ...
I'm going to JMM_ this year to
         give a talk__ on docutils. It’s
Links    a text format and suite of
         scripts with multiple output
         formats.
  ReST
         .. _JMM: http://www.ams.org/
         amsmtgs/2124_intro.html
         __ http://www.ams.org/amsmtgs/
         2124_abstracts/1056-n5-630.pdf
I'm going to JMM_ this year to
           give a talk__ on docutils. It’s
Links      a text format and suite of
           scripts with multiple output
           formats.
   ReST
           .. _JMM: http://www.ams.org/
           amsmtgs/2124_intro.html
           __ http://www.ams.org/amsmtgs/
           2124_abstracts/1056-n5-630.pdf

           I'm going to JMM this year to give a talk on
Rendered   docutils. It’s a text format and suite of scripts
   HTML    with multiple output formats.
Demonstration
           ∞
           1       π2
                2
                  =
          n=1
              n     6
Adding LaTeX to ReST
Do an example such as :latex:`$int x^2
e^x,dx$` where they have to integrate
by parts twice, an example such
as :latex:`$int e^x sin x,dx$` where
they have to integrate by parts twice
then solve for the original integral,
and an example where :latex:`$dv = dx$`
works.
Adding a role to docutils
def latex_role(role, rawtext, text, lineno,
inliner,options={}, content=[]):
     Latex role. 

    i = rawtext.find('`')
    tex = rawtext[i+1:-1]
    return latex_math(tex), []

def register():
    register_canonical_role('latex',
latex_role)
Adding a role to docutils
def latex_role(role, rawtext, text, lineno,
inliner,options={}, content=[]):
     Latex role. 

    i = rawtext.find('`')
    tex = rawtext[i+1:-1]
    return latex_math(tex), []

def register():
    register_canonical_role('latex',
latex_role)
Adding a role to docutils
def latex_role(role, rawtext, text, lineno,
inliner,options={}, content=[]):
     Latex role. 

    i = rawtext.find('`')
    tex = rawtext[i+1:-1]
    return latex_math(tex), []

def register():
    register_canonical_role('latex',
latex_role)
Processing LaTeX

                ∞
                1       π2
                     2
                       =
               n=1
                   n     6




with demos
Processing LaTeX
•latex + dvipng
                   ∞
                   1       π2
                        2
                          =
                  n=1
                      n     6




with demos
Processing LaTeX
•latex + dvipng
•docutils MathML writer    ∞
                           1
                              n 2
                                  =
                                    π2
                                    6
                          n=1




with demos
Processing LaTeX
•latex + dvipng
•docutils MathML writer    ∞
                           1
                                  =
                                    π2


•tth
                              n 2   6
                          n=1




with demos
TTH
http://hutchinson.belmont.ma.us/tth/
Thanks

                       ∞
                       1       π2
                            2
                              =
                      n=1
                          n     6




@mleingang
#JointMath

A Multiformat Document Workflow With Docutils

  • 1.
    A Multiformat Document Workflow using Docutils Matthew Leingang New York University MAA Session on Publishing Math on the Web San Francisco, CA January 15, 2010
  • 2.
  • 3.
    Multiformat ∞ 1 π2 2 = n=1 n 6
  • 4.
    Multiformat ∞ 1 π2 2 = n=1 n 6 ∞ 1 π2 2 = n=1 n 6
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
    Docutils ∞ 1 π2 http://docutils.sourceforge.net/ n 2 = 6 n=1
  • 14.
    Docutils has manyproducts Python Code
  • 15.
    Docutils has manyproducts Python ReST Code
  • 16.
    Docutils has manyproducts XHTML Python ReST Code
  • 17.
    Docutils has manyproducts XHTML Python ReST Code LaTeX
  • 18.
    Docutils has manyproducts XHTML Python ReST Code LaTeX PDF
  • 19.
    Docutils has manyproducts XHTML Python ReST Code LaTeX troff PDF
  • 20.
    Docutils has manyproducts XHTML Python ReST Code LaTeX PDF troff PDF
  • 21.
    Docutils has manyproducts XHTML XHTML Python ReST Code LaTeX PDF troff PDF
  • 22.
    Docutils has manyproducts XHTML XHTML ReST LaTeX PDF
  • 23.
    ReStuctured Text ishuman- and machine-readable
  • 24.
    ReStuctured Text ishuman- and machine-readable San Francisco is emph{beautiful} LAT EX in January!
  • 25.
    ReStuctured Text ishuman- and machine-readable San Francisco is emph{beautiful} LAT EX in January! San Francisco is HTML strongbeautiful/strong in January!
  • 26.
    ReStuctured Text ishuman- and machine-readable San Francisco is emph{beautiful} LAT EX in January! San Francisco is *beautiful* in ReST January! San Francisco is HTML strongbeautiful/strong in January!
  • 27.
    Sections Title !!!!! Introduction ============ Math on the Web =============== XHTML ----- XHTML is an application ...
  • 28.
    Sections Title !!!!! Introduction ============ Configured by your Math on the Web usage =============== XHTML ----- XHTML is an application ...
  • 29.
    I'm going toJMM_ this year to give a talk__ on docutils. It’s Links a text format and suite of scripts with multiple output formats. ReST .. _JMM: http://www.ams.org/ amsmtgs/2124_intro.html __ http://www.ams.org/amsmtgs/ 2124_abstracts/1056-n5-630.pdf
  • 30.
    I'm going toJMM_ this year to give a talk__ on docutils. It’s Links a text format and suite of scripts with multiple output formats. ReST .. _JMM: http://www.ams.org/ amsmtgs/2124_intro.html __ http://www.ams.org/amsmtgs/ 2124_abstracts/1056-n5-630.pdf I'm going to JMM this year to give a talk on Rendered docutils. It’s a text format and suite of scripts HTML with multiple output formats.
  • 31.
    Demonstration ∞ 1 π2 2 = n=1 n 6
  • 32.
    Adding LaTeX toReST Do an example such as :latex:`$int x^2 e^x,dx$` where they have to integrate by parts twice, an example such as :latex:`$int e^x sin x,dx$` where they have to integrate by parts twice then solve for the original integral, and an example where :latex:`$dv = dx$` works.
  • 33.
    Adding a roleto docutils def latex_role(role, rawtext, text, lineno, inliner,options={}, content=[]): Latex role. i = rawtext.find('`') tex = rawtext[i+1:-1] return latex_math(tex), [] def register(): register_canonical_role('latex', latex_role)
  • 34.
    Adding a roleto docutils def latex_role(role, rawtext, text, lineno, inliner,options={}, content=[]): Latex role. i = rawtext.find('`') tex = rawtext[i+1:-1] return latex_math(tex), [] def register(): register_canonical_role('latex', latex_role)
  • 35.
    Adding a roleto docutils def latex_role(role, rawtext, text, lineno, inliner,options={}, content=[]): Latex role. i = rawtext.find('`') tex = rawtext[i+1:-1] return latex_math(tex), [] def register(): register_canonical_role('latex', latex_role)
  • 36.
    Processing LaTeX ∞ 1 π2 2 = n=1 n 6 with demos
  • 37.
    Processing LaTeX •latex +dvipng ∞ 1 π2 2 = n=1 n 6 with demos
  • 38.
    Processing LaTeX •latex +dvipng •docutils MathML writer ∞ 1 n 2 = π2 6 n=1 with demos
  • 39.
    Processing LaTeX •latex +dvipng •docutils MathML writer ∞ 1 = π2 •tth n 2 6 n=1 with demos
  • 40.
  • 41.
    Thanks ∞ 1 π2 2 = n=1 n 6 @mleingang #JointMath