An experimental textplug to give the feature-block-plugins branch optional full HTML5 compatibility.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. |
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
Experimenting with HTML5 support via a textplug.
The glyph indexing is in need of some work to make it more accessible to textplugs. Perhaps an interface is needed to control and extend the glyphs. In fact the tag HTML5 could be generalised to a glyph replacement modifier. Something like...
...or...
So our example for acronym => abbr. (with existing indexing) might become...
To remove an unwanted glyph, you might do...
...so killing the caps around 3+ uppercase runs would be turned off with something like...
The span markup patterns and replacements could be extendible if they were pulled out of the span() routine too.