Jump to content

trying to copy wiki code


ianco

Recommended Posts

Hi All

 

I want to use wiki style bold (''') and italic ('') code form my form.

 

So, it would be easy to use str_replace() for the opening tag but if you are using '''hello''' to bold the word hello, how can you differentiate the tags? I guess you would need some code to replace this alternatively but I haven't been able to find anything.

 

I think Wikis are built from php so has anyone got any ideas?

 

Many thanks

 

Ian

Link to comment
Share on other sites

HI again,

 

I now want to reverse my preg_replace function

 

$content = preg_replace("/(\\\'\\\')(.*?)(\\\'\\\')/", "<em>$2</em>", $content);

 

This doesn't work:

 

$content = preg_replace("/\<\e\m\>(.*?)\<\/\e\m\>/", "\'\'$1\'\'",$content);

 

any ideas?

 

Thanks

 

Ian

Link to comment
Share on other sites

Right. The best thing is to store two versions of the text: one with the wiki code and one converted to HTML.

... | wikitext   | htmltext
----+------------+----------------------
    | '''Bold''' | Bold

One is for editing, which is converted to HTML when it changes, and the other is so that you don't have to convert the wiki markup every time the content is displayed. No reversing necessary.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.