Bolt\Helpers\Html::decorateTT PHP Method

decorateTT() public static method

Transforms plain text to HTML. Plot twist: text between backticks (`) is wrapped in a element.
public static decorateTT ( string $str ) : string
$str string Input string. Treated as plain text.
return string The resulting HTML
    public static function decorateTT($str)
    {
        $str = htmlspecialchars($str, ENT_QUOTES);
        $str = preg_replace('/`([^`]*)`/', '<tt>\\1</tt>', $str);
        return $str;
    }

Usage Example

Example #1
0
 public function testDecorateTT()
 {
     $input = 'Lorem `ipsum` dolor.';
     $this->assertEquals('Lorem <tt>ipsum</tt> dolor.', Html::decorateTT($input));
 }
All Usage Examples Of Bolt\Helpers\Html::decorateTT