Index: branches/parser-work/phase3/includes/parser/Parser.php |
— | — | @@ -2788,17 +2788,6 @@ |
2789 | 2789 | $this->addTrackingCategory( "$limitationType-category" ); |
2790 | 2790 | } |
2791 | 2791 | |
2792 | | - function transformParseDom($inNode) { |
2793 | | - if ($inNode->nodeName == "newLine") { |
2794 | | - $inNode->setAttribute("tag", "\n"); |
2795 | | - } |
2796 | | - foreach ($inNode->childNodes as $child) { |
2797 | | - if ($child instanceof DOMElement) { |
2798 | | - $this->transformParseDom($child); |
2799 | | - } |
2800 | | - } |
2801 | | - } |
2802 | | - |
2803 | 2792 | /** |
2804 | 2793 | * Return the text of a template, after recursively |
2805 | 2794 | * replacing any variables or templates within the template. |
— | — | @@ -3976,19 +3965,23 @@ |
3977 | 3966 | * @param Title &$title the Title object for the current article |
3978 | 3967 | * @param User $user the User object describing the current user |
3979 | 3968 | * @param ParserOptions $options parsing options |
| 3969 | + * @param bool $clearState whether to clear the parser state first |
3980 | 3970 | * @return string the altered wiki markup |
3981 | 3971 | * @public |
3982 | 3972 | */ |
3983 | | - function preSaveTransform( $text, Title $title, $user, $options ) { |
| 3973 | + function preSaveTransform( $text, Title $title, $user, $options, $clearState = true ) { |
3984 | 3974 | $this->mOptions = $options; |
3985 | 3975 | $this->setTitle( $title ); |
3986 | 3976 | $this->setOutputType( self::OT_WIKI ); |
3987 | | - $this->clearState(); |
3988 | 3977 | |
3989 | | - $parser = new ParseEngine("includes/parser/WikiTextGrammar.xml"); |
3990 | | - $dom = $parser->parse($text); |
3991 | | - $this->transformParseDom($dom->documentElement); |
3992 | | - $text = ParseEngine::unparse($dom->documentElement); |
| 3978 | + if ( $clearState ) { |
| 3979 | + $this->clearState(); |
| 3980 | + } |
| 3981 | + |
| 3982 | + $pairs = array( |
| 3983 | + "\r\n" => "\n", |
| 3984 | + ); |
| 3985 | + $text = str_replace( array_keys( $pairs ), array_values( $pairs ), $text ); |
3993 | 3986 | $text = $this->pstPass2( $text, $user ); |
3994 | 3987 | $text = $this->mStripState->unstripBoth( $text ); |
3995 | 3988 | return $text; |
Index: branches/parser-work/phase3/includes/parser/ParseEngine.php |
— | — | @@ -43,13 +43,13 @@ |
44 | 44 | return $doc; |
45 | 45 | } |
46 | 46 | |
47 | | - static function unparse($inNode) { |
48 | | - $retStr = "" . $inNode->getAttribute("tag"); |
49 | | - foreach ($inNode->childNodes as $child) { |
| 47 | + static function unparse($inNodes) { |
| 48 | + $retStr = ""; |
| 49 | + foreach ($inNodes as $child) { |
50 | 50 | if ($child instanceof DOMText) { |
51 | 51 | $retStr .= $child->data; |
52 | 52 | } else { |
53 | | - $retStr .= self::unparse($child); |
| 53 | + $retStr .= $child->getAttribute("tag") . self::unparse($child->childNodes); |
54 | 54 | } |
55 | 55 | } |
56 | 56 | return $retStr; |
Index: branches/parser-work/phase3/includes/parser/WikiTextGrammar.xml |
— | — | @@ -27,6 +27,11 @@ |
28 | 28 | <Assignment tagName="template" tag="{{"> |
29 | 29 | <Sequence> |
30 | 30 | <Reference name="name" /> |
| 31 | + <Choice failSafe="true"> |
| 32 | + <Assignment tagName="name2" tag=":"> |
| 33 | + <Reference name="main" /> |
| 34 | + </Assignment> |
| 35 | + </Choice> |
31 | 36 | <Reference name="partList" /> |
32 | 37 | <Assignment tagName="endTag" tag="}}" /> |
33 | 38 | </Sequence> |
Index: branches/parser-work/phase3/includes/AutoLoader.php |
— | — | @@ -463,7 +463,6 @@ |
464 | 464 | 'PPNode_Hash_Tree' => 'includes/parser/Preprocessor_Hash.php', |
465 | 465 | 'PPTemplateFrame_DOM' => 'includes/parser/Preprocessor_DOM.php', |
466 | 466 | 'PPTemplateFrame_Hash' => 'includes/parser/Preprocessor_Hash.php', |
467 | | - 'ParseEngine' => 'includes/parser/ParseEngine.php', |
468 | 467 | 'Parser' => 'includes/parser/Parser.php', |
469 | 468 | 'ParserCache' => 'includes/parser/ParserCache.php', |
470 | 469 | 'ParserOptions' => 'includes/parser/ParserOptions.php', |
Index: branches/parser-work/phase3/includes/DefaultSettings.php |
— | — | @@ -1229,11 +1229,6 @@ |
1230 | 1230 | $wgDebugPrintHttpHeaders = true; |
1231 | 1231 | |
1232 | 1232 | /** |
1233 | | - * Log file for debugging the parser, if not set log won't be created |
1234 | | - */ |
1235 | | -$wgDebugParserLog = ''; |
1236 | | - |
1237 | | -/** |
1238 | 1233 | * Show the contents of $wgHooks in Special:Version |
1239 | 1234 | */ |
1240 | 1235 | $wgSpecialVersionShowHooks = false; |