[ANN] markup.py - 1.2 - an HTML/XML generator

D

Daniel Nogradi

A new release of markup.py is available at the sourceforge project page:

http://sourceforge.net/projects/markup/

Markup.py is a set of classes that attempts to make it easier to
generate HTML/XML from a Python program in an intuitive, light-weight,
customizable and pythonic way. Full documentation and examples are
available at

http://markup.sourceforge.net

A quick example:

# example for markup.py

import markup

items = ( "Item one", "Item two", "Item three", "Item four" )
paras = ( "This was a fantastic list.", "And now for something
completely different." )
images = ( "thumb1.jpg", "thumb2.jpg", "more.jpg", "more2.jpg" )

page = markup.page( )
page.init( title="My title",
css=( 'one.css', 'two.css' ),
header="Something at the top",
footer="The bitter end." )

page.ul.open( klass='mylist' )
page.li( items, klass='myitem' )
page.ul.close( )

page.p( paras )
page.img( src=images, width=100, height=80, alt="Thumbnails" )

print page

# end of example

The above code would produce

<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html lang='en'>
<head>
<link media='all' href='one.css' type='text/css' rel='stylesheet' />
<link media='all' href='two.css' type='text/css' rel='stylesheet' />
<title>My title</title>
</head>
<body>
Something at the top
<ul class='mylist'>
<li class='myitem'>Item one</li>
<li class='myitem'>Item two</li>
<li class='myitem'>Item three</li>
<li class='myitem'>Item four</li>
</ul>
<p>This was a fantastic list.</p>
<p>And now for something completely different.</p>
<img width='100' alt='Thumbnails' src='thumb1.jpg' height='80' />
<img width='100' alt='Thumbnails' src='thumb2.jpg' height='80' />
<img width='100' alt='Thumbnails' src='more.jpg' height='80' />
<img width='100' alt='Thumbnails' src='more2.jpg' height='80' />
The bitter end.
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top