List Info

Thread: Re: Markup inside code




Re: Markup inside code
country flaguser name
United States
2007-09-22 10:25:39
On Sep 12, 11:44 am, Christopher Lenz <cml...gmx.de> wrote:
> Am 12.09.2007 um 12:29 schrieb Richard Lewis:
>
>
> This is a fairly common question/concern. For some
answers, see:
>
>    <http://genshi.edgewa
ll.org/wiki/
> GenshiFaq#HowcanIincludeliteralXMLintemplateoutput>
>    <http://genshi.edgewa
ll.org/wiki/
> GenshiTutorial#AllowingMarkupinComments>
>
Cool. The tag object almost looked like the way to do this.
Though, it
would have meant building a proper parse tree of my
Wiki-like markup
in order to handle nested "elements" (e.g. ''[http://www.foobar.baz/
italic link]'').

So I thought instead I would try parsing my Wiki markup into
Genshi
events which wouldn't require a parse tree as such because
it only
needs to know where an element starts and ends; nested
elements will
just result in consecutive START events.

And I now have working code which turns text containing my
application
specific sub-set of Wiki-like markup into a Genshi Stream
instance. It
renders correctly and everything! Very pleased 

I've put the code here: http://
www.richard-lewis.me.uk/genshi-wiki.py
but its a bit messy and I haven't commented it! (And, like I
said, its
application specific.)

The thing that I now need to be able to do is to use this
code from
within a template. I guess I could import my Wiki function
into the
template, call it on the relevant fields, render() the
result, and
then output it to the template using genshi.core.Markup to
stop the
resultant HTML from being escaped. But I'm thinking this may
be a bit
wasteful if there is a way of inserting Genshi event streams
directly
into the event stream being generated by a Genshi template.
Is this
possible?

Cheers,
Richard


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Genshi" group.
To post to this group, send email to genshigooglegroups.com
To unsubscribe from this group, send email to
genshi-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/genshi?hl=en
-~----------~----~----~----~------~----~------~--~---


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )