[ANN] markup.py - 1.2 - an HTML/XML generator
Daniel Nogradi
nogradi at gmail.com
Mon Apr 3 18:09:35 EDT 2006
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>
More information about the Python-list
mailing list