Commit de64fb60 authored by Tobias Haider's avatar Tobias Haider
Browse files

Fix for headlines, input parsing

parent d9db25ef
......@@ -55,26 +55,28 @@ class TweekiHooks {
public static function onOutputPageBeforeHTML( &$out, &$text ) {
$doc = new DOMDocument();
$html = mb_convert_encoding( $text, 'HTML-ENTITIES', 'UTF-8' );
$doc->loadHTML( $html );
$spans = $doc->getElementsByTagName('span');
foreach( $spans as $span ) {
$mw_headline = '';
if( $span->getAttribute('class') == 'mw-headline' ) {
$mw_headline = $span;
/* move the contents of .mw-headline to a newly created .mw-headline-content */
$mw_headline_content = $doc->createElement("span");
$mw_headline_content->setAttribute( 'class', 'mw-headline-content' );
while( $mw_headline->firstChild ) {
$mw_headline_content->appendChild( $mw_headline->removeChild( $mw_headline->firstChild ) );
}
if( $html != '' ) {
$doc->loadHTML( $html );
$spans = $doc->getElementsByTagName('span');
foreach( $spans as $span ) {
$mw_headline = '';
if( $span->getAttribute('class') == 'mw-headline' ) {
$mw_headline = $span;
/* move the contents of .mw-headline to a newly created .mw-headline-content */
$mw_headline_content = $doc->createElement("span");
$mw_headline_content->setAttribute( 'class', 'mw-headline-content' );
while( $mw_headline->firstChild ) {
$mw_headline_content->appendChild( $mw_headline->removeChild( $mw_headline->firstChild ) );
}
/* put .mw-headline before .mw-headline-content */
$mw_headline->parentNode->insertBefore( $mw_headline_content, $mw_headline );
$mw_headline->parentNode->insertBefore( $mw_headline, $mw_headline_content );
/* put .mw-headline before .mw-headline-content */
$mw_headline->parentNode->insertBefore( $mw_headline_content, $mw_headline );
$mw_headline->parentNode->insertBefore( $mw_headline, $mw_headline_content );
}
}
}
$text = $doc->saveHTML($doc->documentElement->firstChild->firstChild);
$text = $doc->saveHTML($doc->documentElement->firstChild->firstChild);
}
}
/**
......@@ -119,21 +121,21 @@ class TweekiHooks {
* Enable TOC
*/
static function TOC( $input, array $args, Parser $parser, PPFrame $frame ) {
return array( '<div class="tweeki-toc">' . $input . '</div>' );
return array( '<div class="tweeki-toc">' . $parser->recursiveTagParse( $input ) . '</div>' );
}
/**
* Enable use of <legend> tag
*/
static function legend( $input, array $args, Parser $parser, PPFrame $frame ) {
return array( '<legend>' . $input . '</legend>', "markerType" => 'nowiki' );
return array( '<legend>' . $parser->recursiveTagParse( $input ) . '</legend>', "markerType" => 'nowiki' );
}
/**
* Enable use of <footer> tag
*/
static function footer( $input, array $args, Parser $parser, PPFrame $frame ) {
return array( '<footer>' . $input . '</footer>', "markerType" => 'nowiki' );
return array( '<footer>' . $parser->recursiveTagParse( $input ) . '</footer>', "markerType" => 'nowiki' );
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment