Edgewall Software

Changes between Version 2 and Version 3 of GenshiRecipes/HtmlTransform


Ignore:
Timestamp:
Sep 12, 2006, 12:33:24 PM (18 years ago)
Author:
cmlenz
Comment:

s/Markup/Genshi

Legend:

Unmodified
Added
Removed
Modified
  • GenshiRecipes/HtmlTransform

    v2 v3  
    1 = [MarkupRecipes Markup Recipes]: Transforming HTML documents =
     1= [GenshiRecipes Genshi Recipes]: Transforming HTML documents =
    22
    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. Markup 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.
     3While 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.
    44
    55Let'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:
     
    4545    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    4646    "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="">
    4848
    4949  <!--! Add a header DIV on top of every page with a logo image -->
     
    7373#!python
    7474import os, sys
    75 from markup.input import HTMLParser
    76 from markup.template import Context, Template
     75from genshi.input import HTMLParser
     76from genshi.template import Context, MarkupTemplate
    7777
    7878def transform(html_filename, tmpl_filename):
    7979    tmpl_fileobj = open(tmpl_filename)
    80     tmpl = Template(tmpl_fileobj, tmpl_filename)
     80    tmpl = MarkupTemplate(tmpl_fileobj, tmpl_filename)
    8181    tmpl_fileobj.close()
    8282
     
    123123
    124124----
    125 See also: MarkupRecipes, MarkupTemplates
     125See also: GenshiRecipes, [wiki:Documentation/xml-templates.html Genshi XML Template Language]