DAT-3402 move links placeholder replacement after markers are resolved

This commit is contained in:
idradm 2015-10-27 14:09:42 +01:00
parent 2424103f76
commit c73cfab57b
3 changed files with 9 additions and 31 deletions

View file

@ -2,8 +2,6 @@
namespace Wikia\PortableInfobox\Parser;
interface ExternalParser {
public function parse( $text );
public function parseRecursive( $text );
public function replaceVariables( $text );

View file

@ -12,28 +12,6 @@ class MediaWikiParserService implements ExternalParser {
$this->frame = $frame;
}
/**
* Method used for parsing wikitext provided through variable
*
* @param $wikitext
*
* @return mixed
*/
public function parse( $wikitext ) {
wfProfileIn( __METHOD__ );
if ( in_array( substr( $wikitext, 0, 1 ), [ '*', '#' ] ) ) {
//fix for first item list elements
$wikitext = "\n" . $wikitext;
}
$parsed = $this->parser->internalParse( $wikitext, false, $this->frame );
$output = $this->parser->doBlockLevels( $parsed, false );
$this->parser->replaceLinkHolders( $output );
wfProfileOut( __METHOD__ );
return $output;
}
/**
* Method used for parsing wikitext provided in infobox that might contain variables
*
@ -43,8 +21,14 @@ class MediaWikiParserService implements ExternalParser {
*/
public function parseRecursive( $wikitext ) {
wfProfileIn( __METHOD__ );
$parsed = $this->parse( $wikitext );
$ready = $this->parser->mStripState->unstripBoth( $parsed );
if ( in_array( substr( $wikitext, 0, 1 ), [ '*', '#' ] ) ) {
//fix for first item list elements
$wikitext = "\n" . $wikitext;
}
$parsed = $this->parser->internalParse( $wikitext, false, $this->frame );
$output = $this->parser->doBlockLevels( $parsed, false );
$ready = $this->parser->mStripState->unstripBoth( $output );
$this->parser->replaceLinkHolders( $ready );
$newlinesstripped = preg_replace( '|[\n\r]|Us', '', $ready );
$marksstripped = preg_replace( '|{{{.*}}}|Us', '', $newlinesstripped );
wfProfileOut( __METHOD__ );

View file

@ -2,12 +2,8 @@
namespace Wikia\PortableInfobox\Parser;
class SimpleParser implements ExternalParser {
public function parse( $text ) {
return $text;
}
public function parseRecursive( $text ) {
return $this->parse( $text );
return $text;
}
public function replaceVariables( $text ) {