$inHeading = false;
// True if there are no more greater-than (>) signs right of $i
$noMoreGT = false;
- // Map of tag name => true if there are no more closing tags of given type right of $i
- $noMoreClosingTag = array();
// True to ignore all input up to the next <onlyinclude>
$findOnlyinclude = $enableOnlyinclude;
// Do a line-start run without outputting an LF character
} else {
$attrEnd = $tagEndPos;
// Find closing tag
- if (
- !isset( $noMoreClosingTag[$name] ) &&
- preg_match( "/<\/" . preg_quote( $name, '/' ) . "\s*>/i",
+ if ( preg_match( "/<\/" . preg_quote( $name, '/' ) . "\s*>/i",
$text, $matches, PREG_OFFSET_CAPTURE, $tagEndPos + 1 )
) {
$inner = substr( $text, $tagEndPos + 1, $matches[0][1] - $tagEndPos - 1 );
$i = $matches[0][1] + strlen( $matches[0][0] );
$close = '<close>' . htmlspecialchars( $matches[0][0] ) . '</close>';
} else {
- // No end tag -- don't match the tag, treat opening tag as literal and resume parsing.
- $i = $tagEndPos + 1;
- $accum .= htmlspecialchars( substr( $text, $tagStartPos, $tagEndPos + 1 - $tagStartPos ) );
- // Cache results, otherwise we have O(N^2) performance for input like <foo><foo><foo>...
- $noMoreClosingTag[$name] = true;
- continue;
+ // No end tag -- let it run out to the end of the text.
+ $inner = substr( $text, $tagEndPos + 1 );
+ $i = $lengthText;
+ $close = '';
}
}
// <includeonly> and <noinclude> just become <ignore> tags
$inHeading = false;
// True if there are no more greater-than (>) signs right of $i
$noMoreGT = false;
- // Map of tag name => true if there are no more closing tags of given type right of $i
- $noMoreClosingTag = array();
// True to ignore all input up to the next <onlyinclude>
$findOnlyinclude = $enableOnlyinclude;
// Do a line-start run without outputting an LF character
} else {
$attrEnd = $tagEndPos;
// Find closing tag
- if (
- !isset( $noMoreClosingTag[$name] ) &&
- preg_match( "/<\/" . preg_quote( $name, '/' ) . "\s*>/i",
+ if ( preg_match( "/<\/" . preg_quote( $name, '/' ) . "\s*>/i",
$text, $matches, PREG_OFFSET_CAPTURE, $tagEndPos + 1 )
) {
$inner = substr( $text, $tagEndPos + 1, $matches[0][1] - $tagEndPos - 1 );
$i = $matches[0][1] + strlen( $matches[0][0] );
$close = $matches[0][0];
} else {
- // No end tag -- don't match the tag, treat opening tag as literal and resume parsing.
- $i = $tagEndPos + 1;
- $accum->addLiteral( substr( $text, $tagStartPos, $tagEndPos + 1 - $tagStartPos ) );
- // Cache results, otherwise we have O(N^2) performance for input like <foo><foo><foo>...
- $noMoreClosingTag[$name] = true;
- continue;
+ // No end tag -- let it run out to the end of the text.
+ $inner = substr( $text, $tagEndPos + 1 );
+ $i = $lengthText;
+ $close = null;
}
}
// <includeonly> and <noinclude> just become <ignore> tags
</p>
!! end
+## PHP parser discards the "<pre " string
!! test
Handle broken pre-like tags (bug 64025)
!! options
<table><pre </table>
!! html/php
<pre>x</pre>
-<table><pre </table>
+<table><pre></pre></table>
-!! html/php+tidy
-<pre>
-x
-</pre>
-<p><pre</p>
!! html/parsoid
<pre about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"a":{"<pre":null},"sa":{"<pre":""},"stx":"html","pi":[[{"k":"1","spc":["","","",""]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<pre <pre>x</pre>"}},"i":0}}]}'>x</pre>
!! wikitext
<includeonly>
!! html
-<p><includeonly>
-</p>
!! end
## We used to, but no longer wt2wt this test since the default serializer
array( "<noinclude> Foo bar </noinclude>", "<root><ignore><noinclude></ignore> Foo bar <ignore></noinclude></ignore></root>" ),
array( "<noinclude>\n{{Foo}}\n</noinclude>", "<root><ignore><noinclude></ignore>\n<template lineStart=\"1\"><title>Foo</title></template>\n<ignore></noinclude></ignore></root>" ),
array( "<noinclude>\n{{Foo}}\n</noinclude>\n", "<root><ignore><noinclude></ignore>\n<template lineStart=\"1\"><title>Foo</title></template>\n<ignore></noinclude></ignore>\n</root>" ),
- array( "<gallery>foo bar", "<root><gallery>foo bar</root>" ),
+ array( "<gallery>foo bar", "<root><ext><name>gallery</name><attr></attr><inner>foo bar</inner></ext></root>" ),
array( "<{{foo}}>", "<root><<template><title>foo</title></template>></root>" ),
array( "<{{{foo}}}>", "<root><<tplarg><title>foo</title></tplarg>></root>" ),
array( "<gallery></gallery</gallery>", "<root><ext><name>gallery</name><attr></attr><inner></gallery</inner><close></gallery></close></ext></root>" ),