Sfoglia il codice sorgente

Add code tag

staging
parent
commit
d09429f3a3
2 ha cambiato i file con 30 aggiunte e 0 eliminazioni
  1. +25
    -0
      app/BbCode/Tag/Code.php
  2. +5
    -0
      app/Helper/BBCode.php

+ 25
- 0
app/BbCode/Tag/Code.php Vedi File

@@ -0,0 +1,25 @@
<?php

namespace App\BbCode\Tag;

use Knockout\BbCode\Tag\TagInterface;
use Knockout\BbCode\Tokenizer\Tag as TokenTag;

class Code implements TagInterface
{

public function format(TokenTag $tokenTag): string
{
return sprintf('<pre>%s</pre>', htmlentities($tokenTag->getText()));
}

public function getName(): string
{
return 'code';
}

public function getOriginalText(TokenTag $tokenTag): string
{
return "[{$this->getName()}]{$tokenTag->getText()}[/{$this->getName()}";
}
}

+ 5
- 0
app/Helper/BBCode.php Vedi File

@@ -13,6 +13,7 @@ use App\BbCode\Tag\Spoiler;
use App\BbCode\Tag\HeadingOne;
use App\BbCode\Tag\HeadingTwo;
use App\BbCode\Tag\Link;
use App\BbCode\Tag\Code;
// quotes
use App\BbCode\Tag\Quote;
use App\BbCode\Tag\Blockquote;
@@ -62,6 +63,9 @@ class BBCode {
$link = new Link();
$parser->addTag($link);

$code = new Code();
$parser->addTag($code);

$quote = new Quote();
$parser->addTag($quote);

@@ -86,6 +90,7 @@ class BBCode {
$strikethrough,
$image,
$link,
$code,
$quote,
$blockquote,
$twitter,


Loading…
Annulla
Salva