Reversing markup

#1
[eluser]gmask[/eluser]
This isn't specific to CodeIgniter, but I'm using the Textile markup tool in an application that I'm building with CodeIgniter, so I figured I'd ask here in case anyone knew what to do:

Like I said I'm using Textile to automatically process the content textarea of a CMS I'm building, and want a way to reverse the Textile markup for editing purposes.

For example, if I write:
Code:
Hello, this is a paragraph

* This is a list item
* This is another list item

This is another paragraph, "and a link!":http://www.codeigniter.com
And submit it to the database, the text is automatically converted to:
Code:
<p>Hello, this is a paragraph</p>

    <ul>
        <li>This is a list item</li>
        <li>This is another list item</li>
    </ul>

<p>This is another paragraph, <a href="http://www.codeigniter.com">and a link!</a></p>
Obviously I love this feature, but would like to extend it a little more so that when I edit the article, the content body that loads is not the latter, but the former.

Does anyone know how I would do this? Google is being extremely unhelpful (automatically de-parsed back into Textile's formatting).

#2
[eluser]gmask[/eluser]
Hey everyone, I actually decided to do something that I think works really well for this situation:

Rather than using a single field in the table for content, I decided to make two: content, and content_textile. That way I can use the content field for inserting and updating, and then process it with Textile for storage in content_textile. Then I just call the content_textile field in my views for display.

If anyone else is in the same boat I was, you might try out my solution. It's a little more work at first, but I think it's probably better in the long run.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.