Sha256: 7ca377b27e6150573309e84178b12256c3caaebfc1c29d776b9118e331e3485e
Contents?: true
Size: 875 Bytes
Versions: 10
Compression:
Stored size: 875 Bytes
Contents
<?php namespace MtHaml\NodeVisitor; use MtHaml\Node\Run; class Midblock extends NodeVisitorAbstract { protected $midblockRegex; public function __construct($midblockRegex) { $this->midblockRegex = $midblockRegex; $this->skip = new \SplObjectStorage; } public function enterRun(Run $node) { do { if (null === $prev = $node->getPreviousSibling()) { break; } if (!$prev instanceof Run) { break; } if (!preg_match($this->midblockRegex, $node->getContent())) { break; } $node->getParent()->removeChild($node); while (null !== $prev->getMidblock()) { $prev = $prev->getMidblock(); } $prev->setMidblock($node); } while (false); } }
Version data entries
10 entries across 10 versions & 1 rubygems