On 7/5/2010 11:23 AM, Steffen Hoffmann wrote:
Christian Boos wrote:
On 7/5/2010 1:03 AM, Steffen Hoffmann wrote:
I figured out that using format_to_html() is a way, if not even the
preferred one, to transform wiki markup to HTML.

Since I want to convert ticket descriptions into HTML that will added to
a plugins output inside a span tag, I am stuck right now: output is
always wrapped by p tag, but that is not allowed inside span tag, and no
way to switch this undesired wrapping off in format_to_html().

If you want to wrap the text in a<span>, you want "inline" HTML anyway,
so not format_to_html but format_to_oneliner.
Right, this came to my mind as well and might be the easy option anyway.
However this will remove i.e. table markup without a trace, while  I
prefer to not just strip but replace preview-incompatible markup with
special code, so while still being a rough preview at least it shows
there actually is something.

preview-incompatible markup     replacement code

  <table ... /table>              [|||]
  <img ... />                     X
  <a ...>LABEL</a>          [LABEL]


sample output

This is some content.
[X]image description here
Well, that could be a problem for calendar presentation,<br/>
if not escaped properly. And this is [X] another image.

This is a bit tricky indeed, I know, but I'd really like to preserve
these additional bits of information in my previews.

As all p tags have to be stripped in this case, not only the surrounding
pair, I've done this is now with Python re. This solution is easy
enough, but I'm still looking to go with even less fiddling with
strings, if possible.

Anyway, thanks for taking care.

Well, I propose to come back to this thread in a few weeks, when I'll have something to show for my new wiki parser / formatter ;-) Your requirement seems to be a nice example for specializing a standard formatter.

Note that if you're in a hurry you /could/ already subclass Formatter now, and prevent the markup you don't want to be generated, but this is much more complex to do now that it will be in 0.13.

-- Christian

--
You received this message because you are subscribed to the Google Groups "Trac 
Development" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/trac-dev?hl=en.

Reply via email to