public function handleInput(FileInterface $scribbleFile) { $this->scribbleFile = $scribbleFile; if (preg_match('/<!-- *scribble-ignore-snippets: *(1|true) *-->/', $scribbleFile->getSource())) { return $scribbleFile->getSource(); } // find all occurences (match entire document) and fire for each occurence $this->regexPart = '(' . $scribbleFile->getLeftKeywordDelimiter() . ' *scribble-snippet: *(.*?) *' . $scribbleFile->getRightKeywordDelimiter() . '( *\\n| *$))'; return preg_replace_callback('/' . $this->regexPart . '/is', array($this, 'includeSnippet'), $scribbleFile->getSource()); }