Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

  1. Index
  2. » Archives
  3. » reverse textile

#1 2004-04-28 10:53:20

djfoobarmatt
New Member
Registered: 2004-04-28
Posts: 6

reverse textile

I’m planning to use textile and texpattern as part of a larger system but would need to be able to import textpattern articles from an external document. The way i thought i’d do it was to convert the doc to xhtml and then do a ‘reverse textile’ conversion if that’s a plausible idea. I can’t find any php that does this so i assume it’s a oneway process textile->xhtml at the moment.

matt

Offline

#2 2004-04-28 13:36:47

jdueck
Plugin Author
From: Minneapolis, MN
Registered: 2004-02-27
Posts: 147
Website

Re: reverse textile

I’m doing the same. Here’s my process.

1. copy article body out of old xhtml page
2. replace all: <code><p></code>, <code><br /></code> with nothing
3. replace all: heading tags and blockquotes with hn and bq
4. replace all: <code>< p class=”</code> with p(
5. replace all stylized quotes with straight-ASCII ones

That’s pretty much all except in a few special cases. With keyboard shortcuts, it goes pretty quick.

(edit: looks like formatting has changed, old tricks no longer work…)

Last edited by jdueck (2006-01-26 16:04:15)

Offline

#3 2004-05-05 12:22:37

djfoobarmatt
New Member
Registered: 2004-04-28
Posts: 6

Re: reverse textile

In case anyone is interested, code for this can be found here

patches and bug reports welcome.

matt

Last edited by djfoobarmatt (2004-05-05 12:23:21)

Offline

#4 2004-05-05 12:47:02

djfoobarmatt
New Member
Registered: 2004-04-28
Posts: 6

Re: reverse textile

Of course i’ve only just realised that most of it is not needed since textile let’s you put xhtml inline and it works ok. Perhaps I can cut out most of it and pass though the tags instead of trying to convert them all back.

matt

Offline

#5 2004-05-18 03:52:30

djfoobarmatt
New Member
Registered: 2004-04-28
Posts: 6

Re: reverse textile

if i do <code><i>italics</i></code> it works – <i>italics</i>

matt

Last edited by djfoobarmatt (2004-05-18 04:00:56)

Offline

#6 2004-06-02 10:11:03

djfoobarmatt
New Member
Registered: 2004-04-28
Posts: 6

Re: reverse textile

see…

source

test

Last edited by djfoobarmatt (2004-06-02 10:12:04)

Offline

#7 2004-12-22 07:34:23

1beb
Plugin Author
From: Canada, Ontario, Toronto
Registered: 2004-11-22
Posts: 169
Website

Re: reverse textile

Anyone still have this script kicking around… I have a tonne of hand coded pages that I refuse to move into txp simply becuase I don’t want to re-write them using textile

Offline

#8 2004-12-22 11:11:58

djfoobarmatt
New Member
Registered: 2004-04-28
Posts: 6

Re: reverse textile

http://www.matthewsmith.id.au/textpattern/classReverseTextile.phps link
http://www.matthewsmith.id.au/textpattern/demo.phps link
http://www.matthewsmith.id.au/textpattern/demo.php link

It’s not very forgiving because it parses as XML. For real HTML needs a bit of html tidy support as well. Apparently it’s possible to get html tidy working in PHP. I find it’s usable on small pages.

Last edited by djfoobarmatt (2004-12-22 11:17:34)

Offline

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

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

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);
</code></p>

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

Problems:

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)

Offline

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

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

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…

[Lee]


Monkeys could have written a better post..

Offline

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

Skubidu
Archived Plugin Author
Registered: 2004-10-23
Posts: 611
Website

Re: reverse textile

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

Offline

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

jdykast
Member
From: Tennessee
Registered: 2004-12-30
Posts: 119
Website

Re: reverse textile

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

Edit:

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)

Offline

  1. Index
  2. » Archives
  3. » reverse textile

Board footer

Powered by FluxBB