protected function guessLineOfCode() { $pattern = sprintf('/%s/m', preg_quote($this->text, '/')); $rawContent = $this->markdown->getRawContent(); $rawContent->replaceString("\r\n", "\n"); $rawContent->replaceString("\r", "\n"); $lines = $rawContent->split('/\\n/'); $lines->each(function (Text $line, $index) use($pattern) { if ($line->match($pattern)) { $this->markdownLineNo = $index + 1; return false; } return true; }); }