mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-15 11:59:56 +00:00
DAT-3402 move links placeholder replacement after markers are resolved
This commit is contained in:
parent
2424103f76
commit
c73cfab57b
|
@ -2,8 +2,6 @@
|
|||
namespace Wikia\PortableInfobox\Parser;
|
||||
|
||||
interface ExternalParser {
|
||||
public function parse( $text );
|
||||
|
||||
public function parseRecursive( $text );
|
||||
|
||||
public function replaceVariables( $text );
|
||||
|
|
|
@ -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__ );
|
||||
|
|
|
@ -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 ) {
|
||||
|
|
Loading…
Reference in a new issue