Hello everybody
Hello Aurelio and thanks for your tool,

Reading the recent queries and answers about txt2tags and suggestions
for the next 3.0, I would like to share the following ideas (it is a bit 
long, you have been warned:) ).
  My main  point is that I would really like to have the ability to 
*simply* customize templates. It appears to be a sub-item of the last 
item for http://code.google.com/p/txt2tags/wiki/v3
I will try to convince the audience that it is worth to let it be a bit 
upper in the hierarchy of improvements.

The general context is the following: how to be able to customize
headers while remaining faithful to txt2tags ideas and concepts:
    - multi-target: no duplication of content
    - the title, etc is really the title...
    - concentrate only on content

I did not very investigate deeply the matter but there seems to be two 
major kinds of solutions regarding customization of headers. The first 
one is to use simple preprocs to expand/replace the default headers. The 
second one is to use the --no-headers option and include or append 
directly the customized headers.

IMHO, the first solution can be quite difficult to implement (depending 
on your knowledge of t2t and/or the TARGET language) or have ascending 
compatibility problem: changing the default headers could break the 
The second solution loose some useful txt2tags features (like the title 
...) and so, if you do not want to loose them, it could end in 
cluttering  the t2t files with distractions, or could imply using other 
processing tools.

Let's have a look at the situation where I want to write a document with
two targets: html and tex. Actually *three*, because I love when the
.t2t source is exactly the .txt I can share with people that are not
necessarily txt2tags aware.

--8<----- A Typical example for customization with --no-headers -----
     The title1
     The title2
     The title3

%!postproc(html): '(?i)(<title>)'       '\1The actual title1'
%!postproc(tex): '(?i)(\title{)'        '\1The same actual title1'
%!postproctrick(html):                  '\1The actual title2'
%!postproctrick(tex):                   '\1The same actual title2'
%!postproctrick(html):                  '\1The actual title3'
%!postproctrick(tex):                   '\1The same actual title3'

%% Do not forget!
%!include(html): ""header.html""
%!include(tex): ""header.tex""

The introduction for the text I am really focussed on....

= Section 1 =

Blah blah

= Section 2 =


%% Do not forget!
%!include(html): ""footer-start.html""
%!include(tex): ""footer-start.tex""
Last modified the %%mtime.
%!include(html): ""footer-end.html""
%!include(tex): ""footer-end.tex""

I would prefer to have my own t2t file to be simply

--8<----- A proposed file -----
     The title1
     The title2
     The title3

The introduction for the text I am really focussed on....

= Section 1 =

Blah blah

= Section 2 =



And the command for processing to be
txt2tags --header-template header -t TARGET file.t2t
and use the appropriate header.TARGET file (see examples below). Such 
files should be fairly easy to create, ie as difficult as creating a 
TARGET file, and requiring no precise knowledge of txt2tags.

As careful readers have remarked,  this improvement does not address the 
footer templates. Trying to fully address the problematic of 
customization, I then propose four possible enhancements regarding the 
implementation of the use of alternative templates:

T1: an option to replace the template from txt2tags.py
     (HEADER_TEMPLATE) by a user file
T2: merge the HEADER_TEMPLATE and EOD tags, add a %(BODY)s that is
     replaced by what is processed from the body part by txt2tags.
T3: introduce new %(STUFF)s macros for templates
T4: possibility to associate (implicitly) a configuration file to any

Imho, T2, ie fully customizable templates with a %(BODY) to be remplaced
by what is processed by txt2tags, should be implemented for v3.

For T3, I don't know if it is already possible to use directly say
%%Mtime in the HEADER_TEMPLATE. I do not think it is.

For T4, the idea is to reduce the number of sub-dialect target requests
(why latex-beamer and not latex-book?), etc...

I also think that the implementation of these ideas would probably not
imply any compatibility break. I underline here that, for the best of my
knowledge, some template customizations by postproc tricks require that
the templates in txt2tags.py do not change too much. That is quite

I finish by exposing some cases of use (and some examples of possible 

   this is the beginning of my post. Actually, it is only adding an
   option to override the hardcoded HEADER_TEMPLATES[TARGET].

   Would address the footer problem in my example.

   This is also a way to have templates that are as close as possible of
   regular target files.
   Somebody *without any txt2tags knowledge* should be able to create a
   template and possibly visualize it (easier in html than in say
   tex wit the current %() syntax though...). Then someone without any
   CSS/XHTML knowledge could use  the template with txt2tags.

   Add %(MTIME)s to add the modification time in the template. Come to
   mind also %(DATE)s, %(TOC)s, %(INFILE)s, %(OUTFILE)s ...
   This yields the question whether to have standard txt2tags directives
   in the templates. Eg, it would be possible to have the same
   customization as for %%Date.

Some examples of possibles templates:
--8<---------------------- template.html -----------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<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">
<BODY BGCOLOR="white" TEXT="black">

<IMG SRC="logo.png"></IMG>

<!-- html code for a nav bar -->

<P ALIGN="center"><CENTER><H1>%(HEADER1)s</H1>


Last Modified the %(MTIME)s.

--8<-------------------- template.tex ---------------------------------
\usepackage[normalem]{ulem} %% needed by strike
\usepackage[%(ENCODING)s]{inputenc}  %% char encoding
\usepackage{%(STYLE)s}  %% user defined


%% No \clearpage.


Last Modified the %(MTIME)s.

   It could be possible to associate a macro bank, a url bank, a smiley
   bank, ..., to a template. It can already be done by including
   configuration files, but it could be more convenient this way.

   It would also be possible to implements sub-dialect of the target
   types. Eg,  proper header for a book in latex is "just" a matter of
   changing \documentclass{article} by \documentclass{book} and all
   \section by \chapter, etc.... This is quite exactly the same for
   latex-beamer (resp.  "beamer" and something
   like "\begin{frame}\frametitle" ...).
   This way, with the right preprocs, one would not have to argue whether
   we should have latex-beamer (as it is (was?) proposed) and not
   latex-book. Any sub-dialect could be prototyped this way (a tex
   template + a configuration file that is automatically loaded) and
   added as a contributed template to the txt2tags package.
   For latex-beamer, it might be also possible to add PAUSE macros or the
   likes. Maybe a solution is better related to the new tagged mark.

   A last case of use was the recent inquiry about latex + R + sweave...

I do agree that my last T4 request is probably not so KISS but I think 
T3 is. The implementation of T3 would be of great interest for me and 
probably other people.

Thanks you for reading all those suggestions,


txt2tags-list mailing list

Reply via email to