Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2005-08-22 11:52:03

New Member
From: Manchester (UK)
Registered: 2004-06-02
Posts: 2

Re: reverse textile

I’ve been playing with this today and foudn the following problems:

I needed to just convert some HTML (not an entire webpage) but by missing out the html and body tags this code produced an error – due to its strict XML handling.

My solution:

  1. add html and body (starting and end tags to my HTML)
  2. perform the reverseTextile function
  3. remove the html and body (starting and end tags)

the code: <p><code>$html = ‘<html><body>’.$text.’</body></html>’; $rt = new ReverseTextile; $text = $rt->ReverseTextileThis($html); $text = preg_replace(‘|<html><body>|’, ‘’,$text); $text = preg_replace(‘|</body</html>|’, ‘’,$text);

The preg_replace’s could be streamlined. I am not the best programmer but the thought is there!


the code doesn’t work too hot with lists. And doesn’t add the space after the # or * thus negating their use to Textile. The code also doesn’t seem to add a carriage return after a list item has been converted to textile.

Last edited by doubleonegative (2005-08-22 11:55:05)


#12 2005-08-22 21:19:51

Plugin Author
From: Boston, MA, US
Registered: 2005-07-25
Posts: 81

Re: reverse textile

This would be an interesting feature for Textpattern’s importing code. I have a ton of posts on my Blogger site that have embedded HTML. Fixing 2200 entries by hand is going to get old pretty quick…


Monkeys could have written a better post..


#13 2005-09-03 10:59:31

Plugin Author
Registered: 2004-10-23
Posts: 611

Re: reverse textile

Is there still anybody working on this? I would love to have the possibility to convert HTML to Textile…


#14 2006-08-19 02:55:07

From: Tennessee
Registered: 2004-12-30
Posts: 119

Re: reverse textile

I ran into an instance where something like this would be helpful. Anyone know of anything happening?


I messed around with it for a bit and found that you don’t need to remove the html and body tags after having a string converted — reverseTextile should take care of that for you. Concerning the truncation that was taking place I think that reverseTextile is looking for the first tag it finds after <html><body> and doesn’t begin “reversing” until then. I just need to use this for snippets rather than entire pages so I added the <html><body> tags that doubleonegative mentioned and then a <p>. So my string to convert code looks like: $string = '<html><body><p>'.$string.'</p></body></html>';.

Also, doubleonegative mentioned that reverseTextile wasn’t adding the spaces after * and # in list items. You can fix this by adding a space after them in the code at lines 279 and 287.

I’m still curious to see if there are other ways of reversing Textile whether it be for snippets of code or for entire pages.

Last edited by jdykast (2006-08-19 03:24:10)


Board footer

Powered by FluxBB