Ejemplo n.º 1
0
$configurator->Censor->add('apple', 'banana');
$configurator->Emoticons->add(':)', '<img src="s.png" alt=":)"/>');
$configurator->Preg->replace('/#(?<tag>[a-z0-9]+)/i', '<a href="https://twitter.com/#!/search/%23{@tag}"><xsl:apply-templates/></a>');
$configurator->HTMLElements->allowElement('a');
$configurator->HTMLElements->allowElement('b');
$configurator->HTMLElements->allowAttribute('a', 'href');
$configurator->HTMLElements->allowAttribute('a', 'title');
$configurator->Autolink;
$configurator->HTMLEntities;
$configurator->FancyPants;
$configurator->MediaEmbed->createIndividualBBCodes = true;
$configurator->MediaEmbed->add('youtube');
$configurator->tags['YOUTUBE']->template = '<iframe width="240" height="180" src="http://www.youtube.com/embed/{@id}" allowfullscreen=""/>';
$configurator->javascript->setMinifier('ClosureCompilerService')->cacheDir = __DIR__ . '/../tests/.cache';
$configurator->javascript->exportMethods = ['disablePlugin', 'enablePlugin', 'preview'];
extract($configurator->finalize(['returnParser' => false, 'returnRenderer' => false]));
ob_start();
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>s9e\TextFormatter &bull; Demo</title>
	<base href="http://s9e.github.io/TextFormatter/demo.html" />
	<style type="text/css">
		#preview
		{
			font-family: sans;
			padding: 5px;
			background-color: #f8f8f8;
			border: dashed 1px #ddd;
Ejemplo n.º 2
0
<?php

include __DIR__ . '/../../src/autoloader.php';
$configurator = new s9e\TextFormatter\Configurator();
$configurator->tags->add('A', ['attributes' => ['href' => ['filterChain' => ['#url'], 'required' => true]], 'template' => '<a href="{@href}"><xsl:apply-templates/></a>']);
$configurator->BBCodes->add('A', ['contentAttributes' => ['href'], 'defaultAttribute' => 'href']);
//==============================================================================
extract($configurator->finalize());
$text = "[a]http://example.org[/a]\n" . "[a=http://example.org]site[/a]";
$xml = $parser->parse($text);
$html = $renderer->render($xml);
echo $html, "\n";
// Outputs:
//
// <a href="http://example.org">http://example.org</a>
// <a href="http://example.org">site</a>
#!/usr/bin/php
<?php 
include __DIR__ . '/../../src/autoloader.php';
$configurator = new s9e\TextFormatter\Configurator();
$tag = $configurator->tags->add('X');
$tag->attributes->add('x')->filterChain->append('#url');
$tag->template = '<a href="{@url}"><xsl:apply-templates/></a>';
$configurator->rendering->engine = 'PHP';
$configurator->finalize();
$scores = $relations = array();
foreach (get_declared_classes() as $className) {
    if (strpos($className, 's9e\\TextFormatter\\Configurator\\') !== 0) {
        continue;
    }
    $scores[$className] = 0;
    $relations[$className] = array();
    $class = new ReflectionClass($className);
    foreach ($class->getInterfaceNames() as $interfaceName) {
        if (strpos($interfaceName, 's9e\\TextFormatter\\Configurator\\') !== 0) {
            continue;
        }
        $scores[$interfaceName] = 0;
        $relations[$className][] = $interfaceName;
    }
    if (method_exists($class, 'getTraitNames')) {
        foreach ($class->getTraitNames() as $traitName) {
            if (strpos($traitName, 's9e\\TextFormatter\\Configurator\\') !== 0) {
                continue;
            }
            $scores[$traitName] = 0;
            $relations[$className][] = $traitName;