Textile lists without the rest

14 July 2008 6:49 PM (4 months, 3 weeks ago) | Filed under code

I have a client who wanted a way of doing lists without all of the coding overhead, and without using the visual editor in WordPress. I immediately thought of Textile, and installed TextileWrapper. It worked great for lists. However, it munged in a spectacular way the rest of the site, riding roughshod over her existing markup.

I tend to give each site that I make a custom WordPress plugin of bits and pieces that come in handy. Filters for text, little functions like time_since() and has_tags(), that sort of thing. To this, I added the following:

require_once( "classTextile.php" );

function textile( $s ) { 
  $textile = new Textile;
  return $textile->fList( $s );
}

function textile_lists( $c ) {
  return preg_replace_callback( "/^[#*]+?.*.(^[^#*])/smU" , "textile" , $c );
}

add_filter( 'the_content' , 'textile_lists' , 6);
add_filter( 'the_excerpt' , 'textile_lists' , 6);
// add_filter( 'comment_text' , 'textile_lists' , 6);

I also uploaded classTextile.php to the plugins directory.

A caveat: it gets a teensy bit wonky when the list is the last thing in the entry and there is no linebreak after the last entry in the list. Just make sure there’s a linebreak after the last list item and everything will be fine.

Comments on "Textile lists without the rest"

Leave a comment | Trackback | Comments feed (RSS 2.0)

Sorry, there are not any comments on this entry yet. Would you like to leave a comment?

Leave a reply



XHTML: You may use these tags:

This entry was written 4 months, 3 weeks ago. You may want to use the search function for a more recent entry on this topic.

Copyright © 2003-2008.
Entries (RSS) | Comments (RSS).
XHTML 1.0 Strict, CSS, RSS, 508.