[t2t] [Patch] Templates in txt2tags
Brought to you by:
aureliojargas
|
From: Emmanuel G. <emm...@li...> - 2010-03-02 20:46:41
|
Some times ago, I suggest the possibility to use templates with txt2tags http://sourceforge.net/mailarchive/message.php?msg_name=499BDB6F.4000204%40cmi.univ-mrs.fr As an attachment, here is a simple patch (against last svn) for this. It implements the specification T3, as it was called in my old post. Basically, it adds an option to select a file, where there is a %(BODY)s macro that will be replaced that was is processed from the t2t markup. This is way easier to tweak the default templates than using postprocs. Just a warning for the LaTeX target, due to its special use in python, always double the %... You can also use txt2tags macros for free in the template. Here is an example <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <META NAME="generator" CONTENT="http://txt2tags.sf.net"> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=%(ENCODING)s"> <!-- A lot of META, robot, IE hacks can be added --> <LINK REL="stylesheet" TYPE="text/css" HREF="%(STYLE)s"> <TITLE>%(HEADER1)s</TITLE> </HEAD> <BODY BGCOLOR="white" TEXT="black"> <IMG SRC="logo.png"></IMG> <!-- html code for a nav bar --> <P ALIGN="center"><CENTER><H1>%(HEADER1)s</H1> <FONT SIZE="4"> <I>%(HEADER2)s</I><BR> %(HEADER3)s </FONT></CENTER> %(BODY)s Last Modified on %%MTIME(%A %d %B). (<a href="%%INFILE">source</a>) </BODY> Save it as template.html, then you go txt2tags -T template -t html myfile.t2t I have been using it for some times, and "it seems to work". If the audience would like to share its thoughts on it... Regards, Emmanuel |