$el = new Texy\HtmlElement('a'); $el->attrs['href'] = '#comm-' . $refName; // set link destination $el->attrs['class'][] = 'comment'; // set class name $el->attrs['rel'] = 'nofollow'; // enable rel="nofollow" $el->setText("[{$refName}] {$name}:"); // set link label (with Texy formatting) return $el; } $texy = new Texy(); // references link [1] [2] will be processed through user function $texy->addHandler('newReference', 'newReferenceHandler'); // configuration Texy\Configurator::safeMode($texy); // safe mode prevets attacker to inject some HTML code and disable images // how generally disable links or enable images? here is a way: // $disallow = array('image', 'figure', 'linkReference', 'linkEmail', 'linkURL', 'linkQuick'); // foreach ($diallow as $item) // $texy->allowed[$item] = FALSE; // processing $text = file_get_contents('sample.texy'); $html = $texy->process($text); // that's all folks! // echo formated output header('Content-type: text/html; charset=utf-8'); echo $html; // do some antispam filtering - this is just very simple example ;-) $spam = FALSE; foreach ($texy->summary['links'] as $link) {
// 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>'; Texy\Configurator::safeMode($texy); doIt($texy); echo '<h2>disableLinks() - disable all links</h2>'; Texy\Configurator::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 = ['myExtraTag' => ['attr1'], 'strong' => []]; doIt($texy);