Fix <noautolinks> tag in parse-on-render mode.

- Fix: <noautolinks> tag did not work in parse-on-render mode.
This commit is contained in:
Daniel Kraus
2017-09-06 22:31:59 +02:00
parent c99ec87b87
commit 04c1be307b
4 changed files with 69 additions and 10 deletions

View File

@ -47,10 +47,15 @@ class ExtensionTest extends LinkTitles\TestCase {
'This page should link to the [[link target]] but not to test page'
],
[
false,
false, // parseOnEdit
'This page should *not* link to the link target',
'This page should *not* link to the link target'
]
],
[
true, // parseOnEdit
'With __NOAUTOLINKS__, this page should not link to the link target',
'With __NOAUTOLINKS__, this page should not link to the link target'
],
];
}
@ -65,8 +70,7 @@ class ExtensionTest extends LinkTitles\TestCase {
] );
$title = $this->insertPage( 'test page', $input )['title'];
$page = new WikiPage( $title );
$content = $page->getContent();
$output = $content->getParserOutput( $title, null, null, false );
$output = $page->getParserOutput( new ParserOptions(), null, true );
$lines = explode( "\n", $output->getText() );
$this->assertRegexp( $expectedOutput, $lines[0] );
}
@ -75,14 +79,34 @@ class ExtensionTest extends LinkTitles\TestCase {
return [
[
true, // parseOnRender
'This page should link to the link target but not to test page',
'_This page should link to the <a href=[^>]+>link target</a> but not to test page_'
'This page should link to the link target but not to the test page',
'_This page should link to the <a href=[^>]+>link target</a> but not to the test page_'
],
[
false,
false, // parseOnRender
'This page should not link to the link target',
'_This page should not link to the link target_'
]
],
[
true, // parseOnRender
'__NOAUTOLINKS__With noautolinks magic word, this page should not link to the link target',
'_With noautolinks magic word, this page should not link to the link target_'
],
[
true, // parseOnRender
'__NOAUTOLINKS__With noautolinks magic word, <autolinks>link target in autolinks tag</autolinks> should be linked',
'_With noautolinks magic word, <a href=[^>]+>link target</a> in autolinks tag should be linked_'
],
[
true, // parseOnRender
'<noautolinks>In a noautolinks tag, link target should NOT be linked</noautolinks>',
'_In a noautolinks tag, link target should NOT be linked_'
],
[
true, // parseOnRender
'<noautolinks>In a noautolinks tag, <autolinks>link target in autolinks tag</autolinks> should be linked</noautolinks>',
'_In a noautolinks tag, <a href=[^>]+>link target</a> in autolinks tag should be linked_'
],
];
}
}

View File

@ -105,6 +105,12 @@ class SplitterTest extends MediaWikiTestCase {
// "With parseHeadings = false,\n==an improperly formatted heading may be linked=\n",
// [ "With parseHeadings = false,\n==an improperly formatted heading may be linked=\n" ]
// ],
[
true, // skipTemplates
true, // parseHeadings
"Text <noautolinks>in noautolinks tag</noautolinks>should be excluded",
[ "Text ", "<noautolinks>in noautolinks tag</noautolinks>", "should be excluded" ]
],
];
}
}