ParserTests: add <pwraptest> and <spantag> tags for use in parser tests
The <pwraptest> extension tag helps test paragraph-wrapping issues. The <spantag> tag behaves like a simplified version of <ref> and is used to test behavior in a standalone way without requiring the Cite extension to be installed. Bug: T354215 Change-Id: I73f4fa256fb9e61804a2722ac350e26423b633ca
This commit is contained in:
parent
469da73183
commit
fac9f7f17d
1 changed files with 18 additions and 0 deletions
|
|
@ -35,6 +35,8 @@ class ParserTestParserHook {
|
|||
$parser->setHook( 'tåg', [ __CLASS__, 'dumpHook' ] );
|
||||
$parser->setHook( 'statictag', [ __CLASS__, 'staticTagHook' ] );
|
||||
$parser->setHook( 'asidetag', [ __CLASS__, 'asideTagHook' ] );
|
||||
$parser->setHook( 'pwraptest', [ __CLASS__, 'pWrapTestHook' ] );
|
||||
$parser->setHook( 'spantag', [ __CLASS__, 'spanTagHook' ] );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -77,4 +79,20 @@ class ParserTestParserHook {
|
|||
public static function asideTagHook(): string {
|
||||
return Html::element( 'aside', [], 'Some aside content' );
|
||||
}
|
||||
|
||||
public static function pWrapTestHook(): string {
|
||||
return '<!--CMT--><style>p{}</style>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $in
|
||||
* @param array $argv
|
||||
* @param Parser $parser
|
||||
* @return string
|
||||
*/
|
||||
public static function spanTagHook( $in, $argv, $parser ): string {
|
||||
return '<span>' .
|
||||
Parser::stripOuterParagraph( $parser->recursiveTagParse( $in ) ) .
|
||||
'</span>';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue