/** * @return \Texy */ public function createTexyForComment() { $texy = new \Texy(); $texy->headingModule->top = 3; $texy->setOutputMode(\Texy::HTML5); // Images $texy->imageModule->root = '.' . $this->imagesRoot; $texy->imageModule->fileRoot = $this->imagesFileRoot; \TexyConfigurator::safeMode($texy); \TexyConfigurator::disableImages($texy); //$texy->allowed['blockquote'] = false; $texy->allowed['emoticon'] = false; $texy->allowed['heading/underlined'] = false; $texy->allowed['heading/surrounded'] = false; $texy->allowed['horizline'] = false; //$texy->allowed['html/tag'] = false; $texy->allowed['html/comment'] = false; //$texy->allowed['list'] = false; //$texy->allowed['list/definition'] = false; $texy->allowed['script'] = false; $texy->allowed['table'] = false; $texy->linkModule->forceNoFollow = true; $texy->addHandler('block', [$this, 'blockHandler']); return $texy; }
/** * Обработать строку (вся разметка): */ public static function markup($text, $safeMode = true, $links = true, $board = null) { $texy = self::createTexyObject($links, $board); if ($safeMode) { TexyConfigurator::safeMode($texy); TexyConfigurator::disableImages($texy); } return $texy->process($text); }
public function __construct() { parent::__construct(); // safe mode \TexyConfigurator::safeMode($this); // output $this->setOutputMode(self::HTML4_TRANSITIONAL); $this->htmlOutputModule->removeOptional = false; self::$advertisingNotice = false; $this->allowed['heading/surrounded'] = false; $this->allowed['heading/underlined'] = false; $this->allowed['link/definition'] = false; $this->allowed['image/definition'] = false; $this->mergeLines = false; $this->addHandler('phrase', array(__CLASS__, 'linkHandler')); }
public function __construct() { parent::__construct(); // output $this->setOutputMode(self::HTML4_TRANSITIONAL); $this->htmlOutputModule->removeOptional = false; self::$advertisingNotice = false; // safe mode TexyConfigurator::safeMode($this); $this->allowed['heading/surrounded'] = false; $this->allowed['heading/underlined'] = false; $this->allowed['link/definition'] = false; $this->allowed['image/definition'] = false; // spojování textu v odstavcích po enteru $this->mergeLines = true; // přidání target="_blank" k odkazům // $this->addHandler('phrase', array(__CLASS__, 'addTargetHandler')); }
// processing $text = file_get_contents('sample.texy'); $html = $texy->process($text); // that's all folks! // echo formated output echo $html; // and echo generated HTML code echo '<pre>'; echo htmlSpecialChars($html); echo '</pre>'; echo '<hr />'; } header('Content-type: text/html; charset=utf-8'); echo '<h2>Enable nearly all valid tags</h2>'; // by default doIt($texy); echo '<h2>Texy::ALL - enables all tags</h2>'; $texy->allowedTags = Texy::ALL; doIt($texy); echo '<h2>safeMode() - enables only some "safe" tags</h2>'; TexyConfigurator::safeMode($texy); doIt($texy); echo '<h2>disableLinks() - disable all links</h2>'; TexyConfigurator::disableLinks($texy); doIt($texy); echo '<h2>Texy::NONE - disables all tags</h2>'; $texy->allowedTags = Texy::NONE; doIt($texy); echo '<h2>Enable custom tags</h2>'; $texy->allowedTags = array('myExtraTag' => array('attr1'), 'strong' => array()); doIt($texy);
} return $invocation->proceed(); } $GLOBALS['wiki_format'] = function (&$content) { $cache = $GLOBALS['dir']['cache'] . md5($content) . $GLOBALS['cache_ext']; if ($GLOBALS['enable_cache'] && file_exists($cache)) { $content = file_get_contents($cache) . '<!-- THIS FILE WAS CACHED IN ' . $cache . ' -->'; } else { if (!(require_once $GLOBALS['texy_path'])) { wiki_perror('Cannot load: ' . $GLOBALS['texy_path']); return false; } if (!isset($GLOBALS['texy'])) { $GLOBALS['texy'] = new Texy(); if ($GLOBALS['paranoia']) { TexyConfigurator::safeMode($GLOBALS['texy']); } $GLOBALS['texy']->encoding = $GLOBALS['charset_encoding']; $GLOBALS['texy']->htmlOutputModule->baseIndent = 4; //$GLOBALS['texy']->linkModule->root = '?page='; $GLOBALS['texy']->addHandler('phrase', 'wiki_texy_phraseHandler'); $GLOBALS['texy']->registerLinePattern('wiki_texy_InlineHandler', '#(?<!\\[\\[)\\[\\[(?!\\ |\\[\\[)(.+)' . TEXY_MODIFIER . '?(?<!\\ |\\]\\])\\]\\](?!\\]\\])()#U', 'wikilink'); /*$GLOBALS['texy']->registerLinePattern( 'wiki_texy_InlineHandler', // callback function or method '#(?<!\[)\[(?!\ |\[)(.+)'.TEXY_MODIFIER.'?(?<!\ |\])\](?!\])()#U', // regular expression 'wikilink' // any syntax name );*/ } $content = $GLOBALS['texy']->process($content); file_put_contents($cache, $content); }