Parse Truncated Wiki Text Question

2 views
Skip to first unread message

Jerry

unread,
Jan 7, 2009, 5:55:25 PM1/7/09
to creoleparser
Hi,

Is there a way to properly parse a truncated Wiki text?

For example, how to properly display the first 19 user-character of a
long wiki text --

"""//**a very long message in italics and bold**//"""

by appending the truncated Wiki format **// as --

creole_parser("""//**a very long message**//""") ?

Thanks.

Sincerely,
Jerry

shday

unread,
Jan 7, 2009, 9:30:05 PM1/7/09
to creoleparser
Hi Jerry,

I'd say just truncate the raw text and then run it through
creoleparser. For the example you gave, Creole syntax doesn't require
the closing "**//".

(Links and images would be broken though).

Steve

Jerry

unread,
Jan 7, 2009, 11:41:20 PM1/7/09
to creoleparser
Hi Steve,

Thanks for the quick reply.

Well, even if links and images are ignored for the time being, it
could still get nasty when the truncation ignorantly cuts _on_ the
markup characters and leaves annoying trailings like / or *, of which
a naive detection/resolution logic can be put in place, but then
literal marker {{{}}} should better be taken into account, making it
not only rather clumsy, but also feels like we are re-implementing
some wheel that's already out there...

Is there a way to count the running sum of the number of characters in
the rendered stream?

Sincerely,
Jerry

shday

unread,
Jan 8, 2009, 12:07:17 PM1/8/09
to creoleparser
>
> Is there a way to count the running sum of the number of characters in
> the rendered stream?
>

Not quite sure what you mean here. But creoleparser doesn't count
anything internally, so the answer is probably no.

Can you truncate *after* parsing? It should be easier to work with the
full Genshi stream or xml. For example, you could use method='text'
for rendering (to strip away all the markup) and then truncate the
result:

http://creoleparser.googlecode.com/svn/docs/modules/core.html#creoleparser.core.Parser

Steve



Reply all
Reply to author
Forward
0 new messages