Skip to content

Instantly share code, notes, and snippets.

@netcarver
Created January 23, 2011 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save netcarver/791684 to your computer and use it in GitHub Desktop.
Save netcarver/791684 to your computer and use it in GitHub Desktop.
An experimental textplug to give the feature-block-plugins branch optional full HTML5 compatibility.
<?php
/**
* HTML5 textplug for textile
* ==========================
*
* Makes use of the default block handler implementation. Override by editing this file if you so wish.
*
* Usage
* -----
*
* place "HTML5. On" (without the quotes & note the capitalisation) as the first line of your HTML5 document. Thereafter you should be able to use HTML5
* throughout your document and have textile issue abbrs, instead of acronyms.
*/
Textile::RegisterBlockHandler( 'HTML5', '_textile_html5_block_handler' );
function _textile_html5_block_handler( $textile, $tag, $att, $atts, $ext, $cite, $o1, $o2, $content, $c2, $c1, $eat )
{
if( $tag === 'HTML5' )
{
# Remap the now deprecated 'acronym' with 'abbr'...
$textile->glyph_replace[6] = '<abbr title="$2">$1</abbr>'; # TODO Glyph indexing will need to be made semantic
# No visible output from this blockhandler...
$eat = true;
}
return array($o1, $o2, $content, $c2, $c1, $eat);
}
# None of the following (AFAIK) require special implementations so they use the default textile block implementation
# indicated by a null handler.
Textile::RegisterBlockHandler( 'nav', null );
Textile::RegisterBlockHandler( 'section', null );
Textile::RegisterBlockHandler( 'aside', null );
Textile::RegisterBlockHandler( 'detail', null );
Textile::RegisterBlockHandler( 'header', null );
Textile::RegisterBlockHandler( 'footer', null );
Textile::RegisterBlockHandler( 'address', null );
Textile::RegisterBlockHandler( 'hgroup', null );
Textile::RegisterBlockHandler( 'figure', null );
Textile::RegisterBlockHandler( 'figcaption', null );
# End of file.
@netcarver
Copy link
Author

Actually, an interface to the glyphs and spans would be better -- then core could change the implementation if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment