Markdown with Textpattern
Posted 6. januari 2005, 00:13 [Edited 27. augusti 2007, 13:37]
Start by downloading Michel Fortins PHP Markdown that is a ported version of John Grubers Markdown to PHP.
Getting it to work is very simple, just replace classTextile.php with the markdown code, make sure the file is still named classTextile.php.
We now have a working textpattern install with Markdown instead of Textile, but there is a few things that we have to do to make it work better.
- Make sure textpattern tags not being wrapped with
<p>tags. - Change so comments are wrapped with
<p>tags instead of a new line is done with a<br />.
We start with the wrapped textpattern tags. Open your classTextile.php that now have markdowns PHP code instead.
Goto line #222 and #224 and add |txp(.*) at the end of the both strings, when you are done you will have it like below.
$block_tags_a = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|'.'script|noscript|form|fieldset|iframe|math|ins|del|txp(.*)';$block_tags_b = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|'.'script|noscript|form|fieldset|iframe|math|txp(.*)';- Download this code: /code/040.txt
This will do the trick with textpattern tags that looks like <txp:my_plugin>some text here</txp:my_plugin>. But with tags that looks like <txp:my_plugin /> we have to do another change.
Goto line #289 after the special case for <hr /> tags and insert this bunch of code.
# Special case just for Textpatterns one line tags.$text = preg_replace_callback('{(?:(?<=\n\n)# Startingafter a blank line|# or\A\n?# thebeginning of the doc)(# save in $1[ ]{0,'.$less_than_tab.'}<(txp)(.*)# start tag = $2\b# word break([^<>])*?#/?># the matching end tag[ \t]*(?=\n{2,}|\Z)# followed by a blank line or end of document)}x','_HashHTMLBlocks_callback',$text);- Download this code: /code/039.txt
Thats it, we are now done with the first part. Now lets take a look at the comment part.
In comment.php goto somewhere around line #87, comment out and insert the new changed line like the example below.
// $message = trim(nl2br($textile->TextileThis(strip_tags($message),1,'',$im)));$message = trim($textile->TextileThis(strip_tags($message)));- Download this code: /code/041.txt
Now goto somewhere around line #302 look for $message2db and comment out the line and insert the new line like the example below shows.
//$message2db = addslashes(nl2br($textile->textileThis($message,1,'',$im)));$message2db = addslashes($textile->textileThis($message));- Download this code: /code/042.txt
Thats it!
Nice! But you still get the Textile help. Is there an easy way to change this so you can see the Markdown syntax instead?
This doesn’t work with your ÅÄÖ-converter tho. :(
Any way to fix this?
I get these errors:
[client 127.0.0.1] PHP Fatal error: Call to a member function decode_high() on a non-object in C:\wwwroot\textpattern\publish\taghandlers.php on line 212
[client 127.0.0.1] PHP Notice: Undefined variable: Textile in C:\wwwroot\textpattern\publish\taghandlers.php on line 212
Open /textpattern/include/txp_article.php and look for the function sidehelp(). Then you have to translate the Textile syntax over to Markdowns syntax.
I’m considering moving to Markdown, mainly because I can’t post code (i.e. txp tags) in my comments, as all HTML code is stripped, and it seems there is no way to fix this. At least I couldn’t find it.
Do you know if I replace Textile with Markdown I will be able to post code (tags) on the comments?
I tried your Code transformer for Textpattern, but it doesn’t work for me, Textile simply strip everything between the @
Thanks for any info
life insurance here
globe life insurance and here [URL=”http://life-insurance.superbankonline.info/variable-life-insurance.html”]variable life insurance[/URL]