General Question

richardhenry's avatar

What PHP-based plain text formatting processor do you recommend?

Asked by richardhenry (12692points) June 24th, 2008

* hello * -> hello
_ hello _ -> hello

.etc (without the spaces)

Observing members: 0 Composing members: 0

3 Answers

lefteh's avatar

I usually just write my own.
Two arrays, str_replace or preg_replace, and you’re done (unless you want to add some extra safety measures).

For example, for your two examples, I’d do this:

$search = array(’/\*(.*?)\*/is’, ’/\_(.*?)\_/is’);
$replace = array(’<em>$1</em>’, ’<strong>$1</strong>’);
$string = preg_replace($search, $replace, $string);

Vincentt's avatar

I prefer just allowing HTML (though securing it using HTML Purifier, an excellent yet underused tool) and perhaps add WYMeditor for easy markup. However, Wikipedia knows quite a few and I suppose most of them also have PHP ports or are PHP native, such as TextilePHP.

richardhenry's avatar

Thanks both for your answers. I was considering using Textile, but it’s too bloated for what I need it for really (although very good), and lefteh’s suggestion is the road I was going down if I didn’t find anything. I guess I’ll be writing my own then.

Cheers again!

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther