Summary of Modifications to Textile 2.0 beta

Colin Brown, June 2004 (Last Updated: 24th June 2004)

Introduction

This document describes the enhancements I have made to the php version of Textile to implement some of the features documented in Brad Choate’s perl version.

The changes are described in detail below, but in summary I have:

  1. Implemented extended block syntax (BC’s Documentation)
  2. Improved handling of preformatted text
  3. Implemented a new block modifier, bc (BC’s Documentation) and block escaping (BC’s Documentation)

The source code files in various stages can be downloaded here. classTextile.php includes all the changes; the other versions are referred to in each section below.

Known issues, bugs and fixes implemented since this document was written are described here: Issues, Bugs and Fixes

1. Extended Block Syntax

Source code for this revision: classTextile.cbv3.php

These changes were implemented in a clean copy of classTextile.php as found in textpattern_g118a.zip

My revision numbering starts at cbv3 because cbv1 and cbv2 were early attempts that I discarded.

The first set of changes I made was to implement extended block modifier syntax. For example:

bq.. Block Quote

Another block quote

p. A paragraph

Would be translated into


	<blockquote>
		<p>Block Quote</p>

	<p>Another block quote</p>

	</blockquote>
	<p>A paragraph</p>

The intial block modifier applies to all subsequent blocks until another block modifier or the end of the file is found.

Summary of Changes Made

2. Improved Handling of <pre>

Source code for this revision: classTextile.cbv4.php.

The original version of Textile 2.0 beta created paragraphs inside blocks of text marked up with <pre> tags. This seems wrong, since the text is (pre)formatted. Lines not starting with, but containing <pre> tags, would also be wrapped in <p></p> tags, which seems right, since <pre> is defined as inline by default. The modified version always wraps a <pre> block inside paragraph tags, but no longer inserts <p> tags within the <pre> block.

Details of changes made to the block() method

3. Implementing bc. and bc.. “block code” modifiers, and block escaping

Source code for this revision: classTextile.cbv5.php

Summary of changes to implement bc

This set of changes implemented “bc.” and “bc..”. Fairly substantial modifiactions were required, because code blocks have to be excluded from white space cleaning and paragraph creation. Support for extended block modifiers which terminate in a new line rather than a space was also required, as this is commonly used when including code using “bc..” (and is implemented in Brad Choate’s perl version).

Details of changes to implement bc

Summary of changes to implement escaped blocks

Escaped blocks allow you to switch off textile formatting for a whole block of text. Documented here.

Details of changes to implement escaped blocks

	
		paragraph 1	
		
		==
		escaped stuff
		==
		
		paragaph 2
		

will work, but

		paragraph 1	
		==
		escaped stuff
		==
		
		paragaph 2
		

will not.

This seems reasonable since it is not easy to figure out where the end of paragraph 1 is in this scenario, and blocks are generally separated by two newlines elsewhere in textile.