Have filters add self as dependencies, rm whitespace.
[xhtml-compiler.git] / XHTMLCompiler / DOMFilter / MarkLeadParagraphs.php
blobbb3432301eab57a2067c8034dd8cacd23f82dc64
1 <?php
3 /**
4 * Attaches class="lead" to all leading paragraphs for typography.
5 */
6 class XHTMLCompiler_DOMFilter_MarkLeadParagraphs extends XHTMLCompiler_DOMFilter
9 protected $name = 'MarkLeadParagraphs';
10 protected $className = 'lead';
12 public function __construct($class = false, $name = false) {
13 parent::__construct($name);
14 if ($class) $this->className = $class;
17 public function process(DOMDocument $dom, $page, $manager) {
18 // possibly add some attribute which disables this behavior
19 $nodes = $this->query("//html:p[local-name(preceding-sibling::*[1])!='p']");
20 if ($nodes) $manager->addDependency(__FILE__);
21 foreach ($nodes as $node) {
22 $node->setAttribute('class', $this->className);