Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Minimal textile?
I’ve fallen head over heels in love with textpattern, and have tried equally to fall in love with textile but it just hasn’t been happening. If I didn’t already know HTML and how I want everything to look, textile would be great, but as is I keep butting up against too many things I want to do that aren’t handled elegantly. (for example, I use a lot of divs for block formatting of text, multi-paragraph blockquotes, raw code posting that is aggravating to get ignored properly, etc)
But there are certain aspects of textile that I adore!, such as converting quotes, em-dashes and other character entities. Is there any way short of chopping up classTextile.php to restrict textile processing to certain tags? Any recommended method for doing the classTextile.php editing if necessary? I’m not a PHP wizard by any means, so the references, conditions and such seem a bit daunting.
thanks!
Offline
Re: Minimal textile?
I haven’t devoted that much time to thinking about this, but if you’re just interested in Textile for the punctuation (smart quotes, em-dashes, etc.) <em>and nothing else</em>, maybe you can just turn off Textile and use <a href=“http://www.michelf.com/projects/php-smartypants/”>PHP SmartyPants</a>?
According to the page linked to above, you can use SmartyPants in PHP programs by using the following (or similar) code:
<pre>include_once “smartypants.php”;
$my_text = SmartyPants($my_text);</pre>
so maybe if you add those two lines to all your templates using the <code><txp:php></code> tag, you could get what you want without hacking your install?
Just my two theoretical cents—it’s late and I’m not entirely focused and I have no idea if this is a feasible thing to do. I might wake up tomorrow morning and go, “how big of an idiot can I be?” But it is a possible solution that presented itself to me. Maybe those proficient in PHP could actually make it work…
Last edited by Elenita (2006-02-13 05:28:28)
Offline
Re: Minimal textile?
Elenita -
thanks for such a fast reply, I can’t believe I forgot about Smartypants, I’m so used to seeing it with Markdown that I think of them being a unit. Surprisingly, you can do a drop-in replacement of textile with smartypants — PHPMarkdown has this code built-in, and I just copied it and trimmed it down to make it work with smartypants!
For anyone coming along wanting to do this, just download smartypants.php, rename it to classTextile.php, and drop it in the /textpattern/lib/ directory over the original. Add the following code block to the new classTextile.php file and it will run through smartypants any time an article is marked for textile processing!
<notextile><pre><code> # — Textile Compatibility Mode ———————————————————————-
# Rename this file to “classTextile.php” and it can replace Textile anywhere. if (strcasecmp(substr(FILE, -16), “classTextile.php”) 0) { # Fake Textile class. It calls Smartypants instead. class Textile { function TextileThis($text, $lite='', $encode='', $noimage='', $strict='') { if ($lite ‘’ && $encode == ‘’) $text = Smartypants($text); return $text; } } }</code></pre></notextile>
Always nice when a solution is just a few simple steps away!
(and the fact that it took me about ten tries to get this code to post correctly because textile kept rewriting it despite multiple tags that should have stopped it, just makes me feel better about overwriting the darn thing! :P)
Last edited by nmerriam (2006-02-13 06:43:00)
Offline
Re: Minimal textile?
Ahhh, that didn’t even occur to me. Like you, I’m so used to seeing Markdown and SmartyPants together that using SmartyPants alone never crossed my mind. (Also: I think better after I sleep.)
One thing to keep in mind is to repeat this little hack every time you update; Textile will come back otherwise.
And FYI, the < notextile > tag should escape Textile.
Last edited by Elenita (2006-02-13 15:20:31)
Offline
Re: Minimal textile?
Elenita wrote:
One thing to keep in mind is to repeat this little hack every time you update; Textile will come back otherwise.
And FYI, the < notextile > tag should escape Textile.
Yeah, I saved the Smartypants version of classtextile.php file in some backup places on the server, but being a drop-in replacement for the original is so simple it’s almost embarrassing as a first hack :)
And yes, < notextile > should escape Textile, but it interacts with < pre > and < code > in fascinating and unpredictable ways. Certain orders will produce mostly textile-free code, some will produce a single run-on line of monospace text with a seemingly random bit in the middle processed while the rest is untouched, etc. I’ve no doubt it works great for folks who’ve wrapped their heads around its quirks, my brain is dedicated to holding CSS quirks at the moment :P
Offline
Pages: 1