/** * Parse emmet style attributes * * @param Tag $tag */ public function processBlockTags(Tag $tag) { if ($tag->isInline()) { return; } $text = null; $tag->getText()->replace('/(^{([^:\\(\\)]+)}[ \\t]*\\n?|(?:[ \\t]*|\\n?){([^:\\(\\)]+)}\\n*$)/', function (Text $w) use(&$text) { $text = $w->trim()->trim('{}'); return ''; }); if ($text) { $tag->setAttributes($this->parseAttributes($text)); } }
/** * @param Text $text */ public function processWikiDefinitionList(Text $text) { $text->replace('{ (^ ;[ \\t]*.+\\n (:[ \\t]*.+\\n){1,} ){1,} \\n+ }mx', function (Text $w) { $w->replace('/^;[ \\t]*(.+)\\n((:[ \\t]*.+\\n){1,})/m', function (Text $w, Text $item, Text $content) { $dt = Tag::create('dt')->setText($item); $lines = $content->trim()->ltrim(':')->split('/\\n?^:[ \\t]*/m', PREG_SPLIT_NO_EMPTY); if (count($lines) > 1) { $dd = Tag::create('dd')->setText(Tag::create('p')->setText(trim($lines->join($this->getRenderer()->renderLineBreak() . "\n")))); } else { $dd = Tag::create('dd')->setText($content->trim()); } return $dt->render() . "\n" . $dd->render() . "\n"; }); $tag = Tag::create('dl')->setText("\n" . $w->trim() . "\n"); return $tag->render(); }); }
/** * @param Collection $rules * * @return Collection|\Ciconia\Common\Tag[] */ protected function createBaseTags(Collection $rules) { /* @var Collection|Tag[] $baseTags */ $baseTags = new Collection(); $rules->each(function (Text $cell) use(&$baseTags) { $cell->trim(); $tag = new Tag('td'); if ($cell->match('/^-.*:$/')) { $tag->setAttribute('align', 'right'); } elseif ($cell->match('/^:.*:$/')) { $tag->setAttribute('align', 'center'); } $baseTags->add($tag); }); return $baseTags; }
/** * {@inheritdoc} */ public function renderTag($tagName, $content, $tagType = Tag::TYPE_BLOCK, array $options = array()) { $options = $this->createResolver()->resolve($options); $tag = new Tag($tagName); $tag->setType($tagType); $tag->setText($content); $tag->setAttributes($options['attr']); return $tag->render(); }