For the last few weeks, I have been wrestling with Markdown, Textile and Textpattern in an attempt to fix our comments. We use Markdown for text formatting on Particletree (and we love it), but it’s been making our comments useless. Basically, it was just stripping out the HTML and leaving people with no way to add links to their comments (Textile didn’t work OR Markdown).

Well, I finally figured out how to make everything work in peace and thankfully, you only have to change one line of code. The following refers to Textpattern 4.01. For those that know, installing PHP Markdown is easy. All you have to do is renamed the markdown file to classTextile.php and replace the Textile formatting file of the same name in the ‘textpattern/lib/’. Before you do that though, rename your old classTextile.php so you don’t lose it. For example I rechristened ours classTextile-old.php.

Then find the txplib_misc.php file in your textpattern/lib/ directory. Locate the markup_comment function (around line 1134) and rename the following line:

include_once $txpcfg['txpath'].'/lib/classTextile.php';

so it refers to your original Textile file. Like this:

include_once $txpcfg['txpath'].'/lib/classTextile-old.php';

And boom. You can use Markdown for your articles and have textile formatting in your comments.

HTML Form Builder
Kevin Hale

Getting Textpattern Comments to work with PHP Markdown by Kevin Hale

This entry was posted 5 years ago and was filed under Notebooks.
Comments are currently closed.


  1. James · 5 years ago

    When I first switched to Markdown from Textile, I ran into that problem as well. Then I found Johan Nilsson’s post on TXP and Markdown, applied his changes, and everything Just Worked. Granted, that was back in the days of RC1, but it might be somethign to look into.

  2. Philippe · 5 years ago

    With Textpattern 4.01 you still can use Markdown for comments. Based on the code by Johan Nilsson(linked by James above), you have to make some changes in the same txplib_misc file, same function (markup_comment): two lines need to be commented out, one need to be modified, lines 1144-1147):

    @//$msg = trim(nl2br($textile->TextileThis(strip_tags(deEntBrackets( //$msg //)),1,’’,$im,’’,(@$comment_nofollow ? ‘nofollow’ : ‘’)))); $msg = trim($textile->TextileThis(strip_tags($msg)));@

    That way I get the full range of Markdown formatting, and I can have real block level tags in my comments (I hope this comes out correctly, Textile in Textpattern comments isn’t very good, esp for code).

  3. Matthew Pennell · 5 years ago

    Are the Markdown vs. Textile wars to blame for the screwed-up formatting of your feed?

    Everything is in one big paragraph, and links are not links but are in long-form with square-brackets/normal brackets.

  4. James · 5 years ago

    I just upgraded from 1.0RC1 to 4.0.1, applied the changes to txplib_misc.php, and everything Just Works with PHP Markdown Extra.

  5. Dr.Dorcell · 4 years ago