@@ -45,19 +45,15 @@ public function process(TextInterface $text): TextInterface
45
45
// Remove blockquotes
46
46
$ output = \PhpSpellcheck \preg_replace ('/^\s{0,3}>\s?/ ' , '' , $ output );
47
47
// Remove reference-style links?
48
+
48
49
$ output = \PhpSpellcheck \preg_replace ('/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/ ' , '' , $ output );
49
- /**
50
- * Remove atx-style headers.
51
- *
52
- *@TODO find a way to merge the two regex below
53
- * remove ## Heading ##
54
- */
55
- $ output = \PhpSpellcheck \preg_replace ('/^#{1,6}\s+(.*)(\s+#{1,6})$/m ' , '$1 ' , $ output );
56
- // remove ## Heading
57
- $ output = \PhpSpellcheck \preg_replace ('/^#{1,6}\s+(.*)$/m ' , '$1 ' , $ output );
58
- // Remove emphasis (repeat the line to remove double emphasis)
59
- $ output = \PhpSpellcheck \preg_replace ('/([\*_]{1,3})(\S.*?\S{0,1})\1/ ' , '$2 ' , $ output );
60
- $ output = \PhpSpellcheck \preg_replace ('/([\*_]{1,3})(\S.*?\S{0,1})\1/ ' , '$2 ' , $ output );
50
+ // Remove ## Heading
51
+ $ output = \PhpSpellcheck \preg_replace ('/^#{1,6}\s+(.*?)(?:\s+#{1,6})?$/m ' , '$1 ' , $ output );
52
+ // Remove all layers of emphasis
53
+ while (\PhpSpellcheck \preg_match ('/([\*_]{1,3})(\S.*?\S{0,1})\1/ ' , $ output )) {
54
+ $ output = \PhpSpellcheck \preg_replace ('/([\*_]{1,3})(\S.*?\S{0,1})\1/ ' , '$2 ' , $ output );
55
+ }
56
+
61
57
// Remove list items
62
58
$ output = \PhpSpellcheck \preg_replace ('/^([^\S\r\n]*)\*\s/m ' , '$1 ' , $ output );
63
59
// Remove code blocks
0 commit comments