Hacking WordPress (covers 2.0)

There is an issue related to how WordPress displays PREformatted html.
By default WP translates any post retrieved from the database before displaying it. It uses two filter functions: wptexturize and wpautop, both added to the same filter: the_content. It also translates any other piece of content (Title, Excerpt, …), but I don’t care now.

The function wptexturize is harmless but a bit annoying.
The concept behind WP is keep it simple, isn’t it? If I post a ” I expect a ” to be displayed, not a “ or a ”. Authors always need to see what they mean!

Until an optional setting appears for turning it off, I recommend you to turn it off now.
It’s quite easy. Just edit the file wordpress/wp-includes/default-filters.php and comment out the line that reads

add_filter('the_content', 'wptexturize');

The function wpautop is harmful, so here is a replacement.

Step 1/2
Edit the file wordpress/wp-includes/functions-formatting.php and copy and paste this function after the function wpautop.

function ae_autop( $unprocessed, $br = 1 ) {
	$processed = "<br />n";
	while( strlen( $unprocessed ) > 0 ) {
		$debugging += 1;
		preg_match( '{^([^<]*)?(</?[^>]+?>)?(.*)$}s', $unprocessed, $matches );
		$text = $matches[1]; // as much text as possible before an HTML tag
		$text = str_replace( "n", "<br />n", $text );
		$tag = $matches[2]; // an HTML tag
		$unprocessed = $matches[3]; // the rest of $unprocessed
		if( preg_match( '{<preb}i', $tag ) ) {
			preg_match( '{^(<preb.*?</pre>)?(.*)$}is', $tag . $unprocessed, $skipping );
			$tag = $skipping[1]; // a pre block
			$unprocessed = $skipping[2]; // the rest of $unprocessed
		}
		$processed .= $text . $tag;     
	}
	return $processed; 
}

Step 2/2
Last but not least, edit the file wordpress/wp-includes/default-filters.php and comment out the line that reads

add_filter('the_content', 'wpautop');

After it, add this line

add_filter('the_content', 'ae_autop');

Sort totals in categorized views

Notes calculates totals for categorized views, but does not sort them.
So if you need it anyway, you have to

  1. navigate the categories in the non-sorted but categorized view (by means of the NotesViewEntry… classes)
  2. create a new document for each category with a field to record that total and a field to record that category
  3. add a non-categorized view for showing the new documents with a sorted column for the total field

Here is the LS code for an agent that implements 1- and 2-

{[.=Totals of categories= /enzymes/chili-ls.php]}

(revised text from my own comment 12349447 at Experts-Exchange)