@@ -45,19 +45,15 @@ public function process(TextInterface $text): TextInterface
4545 // Remove blockquotes
4646 $ output = \PhpSpellcheck \preg_replace ('/^\s{0,3}>\s?/ ' , '' , $ output );
4747 // Remove reference-style links?
48+
4849 $ 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+
6157 // Remove list items
6258 $ output = \PhpSpellcheck \preg_replace ('/^([^\S\r\n]*)\*\s/m ' , '$1 ' , $ output );
6359 // Remove code blocks
0 commit comments