Re: [t2t] txt2tags version 3.0 -- Time to rethink everything WAS Customizing headers
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 preprocs. 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)()' '\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 = Bla %% 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"" --8<--- 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 = Bla --8<--- 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 template 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 paradoxical. I finish by exposing some cases of use (and some examples of possible templates). T1: this is the beginning of my post. Actually, it is only adding an option to override the hardcoded HEADER_TEMPLATES[TARGET]. T2: Would address the footer problem in my example. This is also a way to have templates that are
Re: [t2t] txt2tags version 3.0 -- Time to rethink everything WAS Customizing headers
Hello Emmanuel, I don't have the time to answer your e-mail soon, but I must say I've read it all and I liked very much your template ideas! Specially the %(BODY)s one. It's perfect for everybody (me included) who have the need to change the default headers (and footers, in that case). Now I don't see big drawbacks on implementing it, so I hope we can have it for v3. Thanks for your time and for the very detailed and well thought arguing! Bye On Wed, Feb 18, 2009 at 06:57, Emmanuel Godard wrote: > 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 > preprocs. > 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)()' '\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 = > > Bla > > %% 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"" > --8<--- > > 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 = > > Bla > > --8<--- > > > 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 > template > > 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
Re: [t2t] txt2tags version 3.0 -- Time to rethink everything WAS Customizing headers
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 preprocs. 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)()' '\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 = Bla %% 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"" --8<--- 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 = Bla --8<--- 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 template 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 paradoxical. I finish by exposing some cases of use (and some examples of possible templates). T1: this is the beginning of my post. Actually, it is only adding an option to override the hardcoded HEADER_TEMPLATES[TARGET]. T2: Would address the footer problem in my example. This is also a way to have templates that are as close as possibl