process() public method

Converts document in Texy! to (X)HTML code.
public process ( $text, $singleLine = FALSE ) : string
return string output HTML code
示例#1
0
文件: TexyMacro.php 项目: dg/texy
 public function texyClosed(Latte\MacroNode $node)
 {
     $text = $node->content;
     if (preg_match('#^([\\t ]*)\\S#m', $text, $m)) {
         // remove & restore indentation
         $text = str_replace(["\r", "\n" . $m[1]], ['', "\n"], $text);
         $this->texy->htmlOutputModule->baseIndent = strlen($m[1]);
     }
     $restore = [];
     $tokens = $node->tokenizer;
     while ($tokens->isNext()) {
         $module = $tokens->expectNextValue($tokens::T_SYMBOL) . 'Module';
         $tokens->expectNextValue('.');
         $prop = $tokens->expectNextValue($tokens::T_SYMBOL);
         $tokens->expectNextValue('=');
         $value = $tokens->expectNextValue($tokens::T_SYMBOL, $tokens::T_NUMBER);
         if ($tokens->isNext()) {
             $tokens->expectNextValue(',');
         }
         $restore[] = [&$this->texy->{$module}->{$prop}, $this->texy->{$module}->{$prop}];
         $this->texy->{$module}->{$prop} = $value;
     }
     $node->content = $this->texy->process($text);
     foreach ($restore as $info) {
         $info[0] = $info[1];
     }
 }
 protected function createTemplate($class = NULL)
 {
     $template = parent::createTemplate($class);
     $template->addFilter('texy', function ($content) {
         return new \Latte\Runtime\Html($this->texy->process($content));
     });
     $this->registerTexyMacros($this->texy);
     return $template;
 }
示例#3
0
 public function renderEdit($place_id)
 {
     $place = $this->context->createServicePlaces()->wherePrimary($place_id)->fetch();
     $tx = new Texy();
     $tx->alignClasses['left'] = 'fl';
     $tx->alignClasses['right'] = 'fr';
     $tx->imageModule->root = $this->getHttpRequest()->url->baseUrl;
     $tx->imageModule->fileRoot = $this->getHttpRequest()->url->baseUrl;
     $tx->imageModule->linkedRoot = $this->getHttpRequest()->url->baseUrl;
     $tx->linkModule->root = $this->getHttpRequest()->url->baseUrl;
     $tx->headingModule->top = 4;
     $pl = (array) $place->toArray();
     $pl['description'] = $tx->process($pl['description']);
     $this->template->place = $place;
     $this->template->new = false;
     $this['form']->setDefaults($pl);
     $this['form']['categories']->setDefaultValue($place->related('subject_x_category')->fetchPairs('category_id', 'category_id'));
 }