Saturday, September 26, 2009, 6:45:58 PM, DaveG wrote: > Is there a built-in function to strip all pmwiki markup from a string, > leaving just the text? I searched around but didn't see anything > built-in. If no built-in is there a recipe that I could look at the > provides this?
> Background: BlogIt shows the last 8 (or whatever) user comments in the > sidebar -- only the last 60 or so characters are shown, to keep things > short. However, a user could enter a comment with [++++ Some Huge Text > ++++] or %red%colored text%% and so on. What I'd like is a very simple > mechanism to just strip the markup. There isn't. That's why it took me quite a while to add a text-only output mode to the TextExtract recipe. What I ended up with is a stack of preg_replace rules, each for stripping a particular markup from the text. I also used a method I found in MarkupToUnstyled recipe http://www.pmwiki.org/wiki/Cookbook/MarkupToUnstyled to convert links into text, by manipulating the $LinkFunctions array. I did not follow MarkupToUnstyled approach of stripping markup, which is to first have the text converted to HTML, then to strip the HTML tags, as I wanted more control to retain some specific markup. ~Hans _______________________________________________ pmwiki-users mailing list [email protected] http://www.pmichaud.com/mailman/listinfo/pmwiki-users
