mirror of
				https://github.com/diocloid/LinkTitles.git
				synced 2025-10-22 05:42:32 +02:00 
			
		
		
		
	Fix detection of span and div elements without attributes.
- Fix: Better detection of <span> and <div> elements that do not have attributes.
This commit is contained in:
		@@ -135,8 +135,8 @@ class Splitter {
 | 
			
		||||
			'<pre>.*?<\/pre>|<html>.*?<\/html>|' .      // pre/html
 | 
			
		||||
			'<script>.*?<\/script>|' .                  // script
 | 
			
		||||
			'<gallery>.*?<\/gallery>|' .                // gallery
 | 
			
		||||
			'<div.+?>|<\/div>|' .                       // attributes of div elements
 | 
			
		||||
			'<span.+?>|<\/span>|' .                     // attributes of span elements
 | 
			
		||||
			'<div.*?>|<\/div>|' .                       // attributes of div elements
 | 
			
		||||
			'<span.*?>|<\/span>|' .                     // attributes of span elements
 | 
			
		||||
			'<file>[^<]*<\/file>|' .                    // stuff inside file elements
 | 
			
		||||
			'style=".+?"|class=".+?"|' .                // styles and classes (e.g. of wikitables)
 | 
			
		||||
			'<noautolinks>.*?<\/noautolinks>|' .        // custom tag 'noautolinks'
 | 
			
		||||
 
 | 
			
		||||
@@ -221,6 +221,11 @@ class LinkTitlesLinkerTest extends LinkTitles\TestCase {
 | 
			
		||||
				"With parseHeadings = true,\n== a heading with link target in it ==\n should be linked",
 | 
			
		||||
				"With parseHeadings = true,\n== a heading with [[link target]] in it ==\n should be linked",
 | 
			
		||||
			],
 | 
			
		||||
			[
 | 
			
		||||
				true, // parseHeadings
 | 
			
		||||
				"With parseHeadings = true,\n== <span>a heading with link target in ity/span> ==\n should be linked",
 | 
			
		||||
				"With parseHeadings = true,\n== <span>a heading with [[link target]] in ity/span> ==\n should be linked",
 | 
			
		||||
			],
 | 
			
		||||
			[
 | 
			
		||||
				false, // parseHeadings
 | 
			
		||||
				"With parseHeadings = false,\n== a heading with link target in it ==\n should not be linked",
 | 
			
		||||
 
 | 
			
		||||
@@ -86,6 +86,18 @@ class SplitterTest extends MediaWikiTestCase {
 | 
			
		||||
				"With parseHeadings = false,\n==a heading may not be linked==",
 | 
			
		||||
				[ "With parseHeadings = false,\n", "==a heading may not be linked==", '' ]
 | 
			
		||||
			],
 | 
			
		||||
			[
 | 
			
		||||
				true, // skipTemplates
 | 
			
		||||
				true, // parseHeadings
 | 
			
		||||
				"With parseHeadings = true,\n==<span>a heading with spans may be linked</span>==\n",
 | 
			
		||||
				[ "With parseHeadings = true,\n==", "<span>", "a heading with spans may be linked", "</span>", "==\n" ]
 | 
			
		||||
			],
 | 
			
		||||
			[
 | 
			
		||||
				true, // skipTemplates
 | 
			
		||||
				true, // parseHeadings
 | 
			
		||||
				"With parseHeadings = true,\n==<div>a heading with divs may be linked</div>==\n",
 | 
			
		||||
				[ "With parseHeadings = true,\n==", "<div>", "a heading with divs may be linked", "</div>", "==\n" ]
 | 
			
		||||
			],
 | 
			
		||||
			// Improperly formatted headings cannot be dealt with appropriately for now
 | 
			
		||||
			// [
 | 
			
		||||
			// 	true, // skipTemplates
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user