Changes between Version 2 and Version 3 of GenshiRecipes/HtmlTransform
- Timestamp:
- Sep 12, 2006, 12:33:24 PM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GenshiRecipes/HtmlTransform
v2 v3 1 = [ MarkupRecipes MarkupRecipes]: Transforming HTML documents =1 = [GenshiRecipes Genshi Recipes]: Transforming HTML documents = 2 2 3 While [MarkupTemplates Markup templates] need to be valid XML files, that does not mean you can't use Markup to transform “old-school” HTML documents. Markupcan parse HTML input, and apply ''match templates'' to that input, in order to apply any kind of modification, such as adding site-specific chrome.3 While Genshi [wiki:Documentation/xml-templates.html XML templates] need to be valid XML files, that does not mean you can't use Genshi to transform “old-school” HTML documents. Genshi can parse HTML input, and apply ''match templates'' to that input, in order to apply any kind of modification, such as adding site-specific chrome. 4 4 5 5 Let's say you have the following HTML document (maybe produced by some application or component out of your control), and you'd like to integrate it in your site: … … 45 45 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 46 46 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 47 <html xmlns:py="http:// markup.edgewall.org/" py:strip="">47 <html xmlns:py="http://genshi.edgewall.org/" py:strip=""> 48 48 49 49 <!--! Add a header DIV on top of every page with a logo image --> … … 73 73 #!python 74 74 import os, sys 75 from markup.input import HTMLParser76 from markup.template import Context,Template75 from genshi.input import HTMLParser 76 from genshi.template import Context, MarkupTemplate 77 77 78 78 def transform(html_filename, tmpl_filename): 79 79 tmpl_fileobj = open(tmpl_filename) 80 tmpl = Template(tmpl_fileobj, tmpl_filename)80 tmpl = MarkupTemplate(tmpl_fileobj, tmpl_filename) 81 81 tmpl_fileobj.close() 82 82 … … 123 123 124 124 ---- 125 See also: MarkupRecipes, MarkupTemplates125 See also: GenshiRecipes, [wiki:Documentation/xml-templates.html Genshi XML Template Language]