diff --git a/composer.json b/composer.json index 597e41b620..5be8f01ab3 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "s9e/text-formatter", - "version": "1.0.2-dev", + "version": "1.1.0", "type": "library", "description": "Multi-purpose text formatting and markup library. Plugins offer support for BBCodes, Markdown, emoticons, HTML, embedding media (YouTube, etc...), enhanced typography and more.", "homepage": "https://github.com/s9e/TextFormatter/", diff --git a/src/Bundles/Forum/Renderer.php b/src/Bundles/Forum/Renderer.php index cdb53a0105..5cb12523f2 100644 --- a/src/Bundles/Forum/Renderer.php +++ b/src/Bundles/Forum/Renderer.php @@ -11,7 +11,7 @@ class Renderer extends \s9e\TextFormatter\Renderers\PHP protected $params=['L_HIDE'=>'Hide','L_SHOW'=>'Show','L_SPOILER'=>'Spoiler','L_WROTE'=>'wrote:']; protected function renderNode(\DOMNode $node) { - switch($node->nodeName){case'B':$this->out.='';$this->at($node);$this->out.='';break;case'BANDCAMP':$this->out.='';break;case'CENTER':$this->out.='
';$this->at($node);$this->out.='
';break;case'CODE':$this->out.='
hasAttribute('lang'))$this->out.=' class="language-'.\htmlspecialchars($node->getAttribute('lang'),2).'"';$this->out.='>';$this->at($node);$this->out.='
';break;case'COLOR':$this->out.='';$this->at($node);$this->out.='';break;case'DAILYMOTION':$this->out.='';break;case'EMAIL':$this->out.='';$this->at($node);$this->out.='';break;case'EMOJI':$this->out.=''.\htmlspecialchars($node->textContent,2).'';break;case'FACEBOOK':$this->out.='';break;case'FONT':$this->out.='';$this->at($node);$this->out.='';break;case'I':$this->out.='';$this->at($node);$this->out.='';break;case'IMG':$this->out.=''.\htmlspecialchars($node->getAttribute('alt'),2).'hasAttribute('height'))$this->out.=' height="'.\htmlspecialchars($node->getAttribute('height'),2).'"';if($node->hasAttribute('width'))$this->out.=' width="'.\htmlspecialchars($node->getAttribute('width'),2).'"';$this->out.='>';break;case'INDIEGOGO':$this->out.='';break;case'INSTAGRAM':$this->out.='';break;case'KICKSTARTER':$this->out.='hasAttribute('video'))$this->out.=' style="display:inline-block;width:100%;max-width:480px">';else$this->out.=' style="display:inline-block;width:100%;max-width:220px">';$this->out.='';break;case'LI':$this->out.='
  • ';$this->at($node);$this->out.='
  • ';break;case'LIST':if(!$node->hasAttribute('type')){$this->out.='';}elseif((\strpos($node->getAttribute('type'),'decimal')===0)||(\strpos($node->getAttribute('type'),'lower')===0)||(\strpos($node->getAttribute('type'),'upper')===0)){$this->out.='
      hasAttribute('start'))$this->out.=' start="'.\htmlspecialchars($node->getAttribute('start'),2).'"';$this->out.='>';$this->at($node);$this->out.='
    ';}else{$this->out.='';}break;case'LIVELEAK':$this->out.='';break;case'OL':$this->out.='
      ';$this->at($node);$this->out.='
    ';break;case'QUOTE':$this->out.='hasAttribute('author'))$this->out.=' class="uncited"';$this->out.='>
    ';if($node->hasAttribute('author'))$this->out.=''.\htmlspecialchars($node->getAttribute('author'),0).' '.\htmlspecialchars($this->params['L_WROTE'],0).'';$this->at($node);$this->out.='
    ';break;case'S':$this->out.='';$this->at($node);$this->out.='';break;case'SIZE':$this->out.='';$this->at($node);$this->out.='';break;case'SOUNDCLOUD':$this->out.='';break;case'SPOILER':$this->out.='
    '.\htmlspecialchars($this->params['L_SPOILER'],0).' '.\htmlspecialchars($node->getAttribute('title'),0).'
    ';break;case'TABLE':$this->out.='';$this->at($node);$this->out.='
    ';break;case'TD':$this->out.='hasAttribute('align'))$this->out.=' style="text-align:'.\htmlspecialchars($node->getAttribute('align'),2).'"';$this->out.='>';$this->at($node);$this->out.='';break;case'TH':$this->out.='hasAttribute('align'))$this->out.=' style="text-align:'.\htmlspecialchars($node->getAttribute('align'),2).'"';$this->out.='>';$this->at($node);$this->out.='';break;case'TR':$this->out.='';$this->at($node);$this->out.='';break;case'TWITCH':$this->out.='';break;case'TWITTER':$this->out.='';break;case'U':$this->out.='';$this->at($node);$this->out.='';break;case'UL':$this->out.='
      ';$this->at($node);$this->out.='
    ';break;case'URL':$this->out.='hasAttribute('title'))$this->out.=' title="'.\htmlspecialchars($node->getAttribute('title'),2).'"';$this->out.='>';$this->at($node);$this->out.='';break;case'VIMEO':$this->out.='';break;case'VINE':$this->out.='';break;case'WSHH':$this->out.='';break;case'YOUTUBE':$this->out.='';break;case'br':$this->out.='
    ';break;case'e':case'i':case's':break;case'p':$this->out.='

    ';$this->at($node);$this->out.='

    ';break;default:$this->at($node);} + switch($node->nodeName){case'B':$this->out.='';$this->at($node);$this->out.='';break;case'BANDCAMP':$this->out.='';break;case'CENTER':$this->out.='
    ';$this->at($node);$this->out.='
    ';break;case'CODE':$this->out.='
    hasAttribute('lang'))$this->out.=' class="language-'.\htmlspecialchars($node->getAttribute('lang'),2).'"';$this->out.='>';$this->at($node);$this->out.='
    ';break;case'COLOR':$this->out.='';$this->at($node);$this->out.='';break;case'DAILYMOTION':$this->out.='';break;case'EMAIL':$this->out.='';$this->at($node);$this->out.='';break;case'EMOJI':$this->out.=''.\htmlspecialchars($node->textContent,2).'';break;case'FACEBOOK':$this->out.='';break;case'FONT':$this->out.='';$this->at($node);$this->out.='';break;case'I':$this->out.='';$this->at($node);$this->out.='';break;case'IMG':$this->out.=''.\htmlspecialchars($node->getAttribute('alt'),2).'hasAttribute('height'))$this->out.=' height="'.\htmlspecialchars($node->getAttribute('height'),2).'"';if($node->hasAttribute('width'))$this->out.=' width="'.\htmlspecialchars($node->getAttribute('width'),2).'"';$this->out.='>';break;case'INDIEGOGO':$this->out.='';break;case'INSTAGRAM':$this->out.='';break;case'KICKSTARTER':$this->out.='hasAttribute('video'))$this->out.=' style="display:inline-block;width:100%;max-width:480px">';else$this->out.=' style="display:inline-block;width:100%;max-width:220px">';$this->out.='';break;case'LI':$this->out.='
  • ';$this->at($node);$this->out.='
  • ';break;case'LIST':if(!$node->hasAttribute('type')){$this->out.='
      ';$this->at($node);$this->out.='
    ';}elseif((\strpos($node->getAttribute('type'),'decimal')===0)||(\strpos($node->getAttribute('type'),'lower')===0)||(\strpos($node->getAttribute('type'),'upper')===0)){$this->out.='
      hasAttribute('start'))$this->out.=' start="'.\htmlspecialchars($node->getAttribute('start'),2).'"';$this->out.='>';$this->at($node);$this->out.='
    ';}else{$this->out.='
      ';$this->at($node);$this->out.='
    ';}break;case'LIVELEAK':$this->out.='';break;case'OL':$this->out.='
      ';$this->at($node);$this->out.='
    ';break;case'QUOTE':$this->out.='hasAttribute('author'))$this->out.=' class="uncited"';$this->out.='>
    ';if($node->hasAttribute('author'))$this->out.=''.\htmlspecialchars($node->getAttribute('author'),0).' '.\htmlspecialchars($this->params['L_WROTE'],0).'';$this->at($node);$this->out.='
    ';break;case'S':$this->out.='';$this->at($node);$this->out.='';break;case'SIZE':$this->out.='';$this->at($node);$this->out.='';break;case'SOUNDCLOUD':$this->out.='';break;case'SPOILER':$this->out.='
    '.\htmlspecialchars($this->params['L_SPOILER'],0).' '.\htmlspecialchars($node->getAttribute('title'),0).'
    ';break;case'TABLE':$this->out.='';$this->at($node);$this->out.='
    ';break;case'TD':$this->out.='hasAttribute('align'))$this->out.=' style="text-align:'.\htmlspecialchars($node->getAttribute('align'),2).'"';$this->out.='>';$this->at($node);$this->out.='';break;case'TH':$this->out.='hasAttribute('align'))$this->out.=' style="text-align:'.\htmlspecialchars($node->getAttribute('align'),2).'"';$this->out.='>';$this->at($node);$this->out.='';break;case'TR':$this->out.='';$this->at($node);$this->out.='';break;case'TWITCH':$this->out.='';break;case'TWITTER':$this->out.='';break;case'U':$this->out.='';$this->at($node);$this->out.='';break;case'UL':$this->out.='
      ';$this->at($node);$this->out.='
    ';break;case'URL':$this->out.='hasAttribute('title'))$this->out.=' title="'.\htmlspecialchars($node->getAttribute('title'),2).'"';$this->out.='>';$this->at($node);$this->out.='';break;case'VIMEO':$this->out.='';break;case'VINE':$this->out.='';break;case'WSHH':$this->out.='';break;case'YOUTUBE':$this->out.='';break;case'br':$this->out.='
    ';break;case'e':case'i':case's':break;case'p':$this->out.='

    ';$this->at($node);$this->out.='

    ';break;default:$this->at($node);} } public $enableQuickRenderer=\true; protected $static=['/B'=>'','/CENTER'=>'','/CODE'=>'','/COLOR'=>'','/EMAIL'=>'','/FONT'=>'','/I'=>'','/LI'=>'','/OL'=>'','/QUOTE'=>'','/S'=>'','/SIZE'=>'','/SPOILER'=>'','/TABLE'=>'','/TD'=>'','/TH'=>'','/TR'=>'','/U'=>'','/UL'=>'','/URL'=>'','B'=>'','CENTER'=>'
    ','I'=>'','LI'=>'
  • ','OL'=>'
      ','S'=>'','TABLE'=>'','TR'=>'','U'=>'','UL'=>'
        ']; @@ -20,7 +20,7 @@ protected function renderNode(\DOMNode $node) protected function renderQuickTemplate($id, $xml) { $attributes=$this->matchAttributes($xml); - $html='';switch($id){case'/LIST':$attributes=\array_pop($this->attributes);if(!isset($attributes['type']))$html.='
      ';elseif((\strpos($attributes['type'],'decimal')===0)||(\strpos($attributes['type'],'lower')===0)||(\strpos($attributes['type'],'upper')===0))$html.='';else$html.='';break;case'BANDCAMP':$attributes+=['track_num'=>\null,'track_id'=>\null];$html.='';break;case'CODE':$html.='
      \null];$html.='';break;case'EMOJI':$attributes+=['seq'=>\null];$textContent=$this->getQuickTextContent($xml);$html.=''.\htmlspecialchars($textContent,2).'';break;case'FACEBOOK':$attributes+=['type'=>\null,'id'=>\null];$html.='';break;case'KICKSTARTER':$attributes+=['id'=>\null];$html.='';else$html.=' style="display:inline-block;width:100%;max-width:220px">';$html.='';break;case'LIST':$attributes+=['type'=>\null];if(!isset($attributes['type']))$html.='
        ';elseif((\strpos($attributes['type'],'decimal')===0)||(\strpos($attributes['type'],'lower')===0)||(\strpos($attributes['type'],'upper')===0)){$html.='
          ';$this->attributes[]=$attributes;break;case'QUOTE':$html.='params['L_WROTE'],0).'';break;case'SOUNDCLOUD':$attributes+=['secret_token'=>\null,'id'=>\null];$html.='';break;case'SPOILER':$attributes+=['title'=>\null];$html.='
          '.\htmlspecialchars($this->params['L_SPOILER'],0).' '.\str_replace('"','"',$attributes['title']).'
      ';elseif((\strpos($attributes['type'],'decimal')===0)||(\strpos($attributes['type'],'lower')===0)||(\strpos($attributes['type'],'upper')===0))$html.='';else$html.='';break;case'BANDCAMP':$attributes+=['track_num'=>\null,'track_id'=>\null];$html.='';break;case'CODE':$html.='
      \null];$html.='';break;case'EMOJI':$attributes+=['seq'=>\null];$textContent=$this->getQuickTextContent($xml);$html.=''.\htmlspecialchars($textContent,2).'';break;case'FACEBOOK':$attributes+=['type'=>\null,'id'=>\null];$html.='';break;case'KICKSTARTER':$attributes+=['id'=>\null];$html.='';else$html.=' style="display:inline-block;width:100%;max-width:220px">';$html.='';break;case'LIST':$attributes+=['type'=>\null];if(!isset($attributes['type']))$html.='
        ';elseif((\strpos($attributes['type'],'decimal')===0)||(\strpos($attributes['type'],'lower')===0)||(\strpos($attributes['type'],'upper')===0)){$html.='
          ';$this->attributes[]=$attributes;break;case'QUOTE':$html.='params['L_WROTE'],0).'';break;case'SOUNDCLOUD':$attributes+=['secret_token'=>\null,'id'=>\null];$html.='';break;case'SPOILER':$attributes+=['title'=>\null];$html.='
          '.\htmlspecialchars($this->params['L_SPOILER'],0).' '.\str_replace('"','"',$attributes['title']).'