AsTeX

Why?

How

ElementTreeFactory

This code...

some_list = ['foo', 'bar', 'baz']
print(tostring(
    tag.html(
        tag.head(
            tag.title('My document title')
        ),
        tag.body(
            tag.h1('A heading', class_="heading"),
            tag.p('This is a paragraph'),
            tag.ul(
                tag.li('Item %d = %s' % (n, item))
                for (n, item) in enumerate(some_list)
            )
        )
    )
))

Produces this XML...

<html>
    <head>
        <title>My document title</title>
    </head>
    <body>
        <h1 class="heading">A heading</h1>
        <p>This is a paragraph</p>
        <ul>
            <li>Item 0 = foo</li>
            <li>Item 1 = bar</li>
            <li>Item 2 = baz</li>
        </ul>
    </body>
</html>

(okay, without the pretty indentation)

Err ... wasn't this about LaTeX?

This code...

some_list = ['foo', 'bar', 'baz']
print(tex(
    tag.document(
        tag.topmatter(
            title='My document title',
            author_name='Fred Flintstone'
        ),
        tag.section(
            tag.p('This is a paragraph'),
            tag.ul(
                tag.li('Item %d = %s' % (n, item))
                for (n, item) in enumerate(some_list)
            ),
            title='A heading'
        )
    )
))

Produces this LaTeX...

\documentclass[10]{article}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
\usepackage[paper=a4paper]{geometry}
\usepackage{fixltx2e}
\usepackage{color}
\usepackage[font=small,labelfont=bf]{caption}
\usepackage[bookmarks=true,unicode=true]{hyperref}
\usepackage[all]{hypcap}
\hypersetup{
    colorlinks=true,%
    linkcolor=black,%
    citecolor=black,%
    filecolor=blue,%
    urlcolor=blue}
\begin{document}
\title{My document title}
\author{Fred Flintstone}
\maketitle 

\newpage 
\section{A heading}
This is a paragraph

\begin{itemize}

\item Item 0 = foo
\item Item 1 = bar
\item Item 2 = baz
\end{itemize}

\end{document}

Err ... wasn't this about PDFs?

How to make an actual PDF out of this...

pdflatex test.tex

Repeat ad nauseum...

Conclusion

/

#