[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * @package s9e\TextFormatter 5 * @copyright Copyright (c) 2010-2019 The s9e Authors 6 * @license http://www.opensource.org/licenses/mit-license.php The MIT License 7 */ 8 namespace s9e\TextFormatter\Plugins\Litedown\Parser; 9 class ParsedText 10 { 11 public $decodeHtmlEntities = \false; 12 protected $hasEscapedChars = \false; 13 public $hasReferences = \false; 14 public $linkReferences = []; 15 protected $text; 16 public function __construct($text) 17 { 18 if (\strpos($text, '\\') !== \false && \preg_match('/\\\\[!"\'()*[\\\\\\]^_`~]/', $text)) 19 { 20 $this->hasEscapedChars = \true; 21 $text = \strtr( 22 $text, 23 [ 24 '\\!' => "\x1B0", '\\"' => "\x1B1", "\\'" => "\x1B2", '\\(' => "\x1B3", 25 '\\)' => "\x1B4", '\\*' => "\x1B5", '\\[' => "\x1B6", '\\\\' => "\x1B7", 26 '\\]' => "\x1B8", '\\^' => "\x1B9", '\\_' => "\x1BA", '\\`' => "\x1BB", 27 '\\~' => "\x1BC" 28 ] 29 ); 30 } 31 $this->text = $text . "\n\n\x17"; 32 } 33 public function __toString() 34 { 35 return $this->text; 36 } 37 public function charAt($pos) 38 { 39 return $this->text[$pos]; 40 } 41 public function decode($str) 42 { 43 if ($this->decodeHtmlEntities && \strpos($str, '&') !== \false) 44 $str = \html_entity_decode($str, \ENT_QUOTES, 'UTF-8'); 45 $str = \str_replace("\x1A", '', $str); 46 if ($this->hasEscapedChars) 47 $str = \strtr( 48 $str, 49 [ 50 "\x1B0" => '!', "\x1B1" => '"', "\x1B2" => "'", "\x1B3" => '(', 51 "\x1B4" => ')', "\x1B5" => '*', "\x1B6" => '[', "\x1B7" => '\\', 52 "\x1B8" => ']', "\x1B9" => '^', "\x1BA" => '_', "\x1BB" => '`', 53 "\x1BC" => '~' 54 ] 55 ); 56 return $str; 57 } 58 public function indexOf($str, $pos = 0) 59 { 60 return \strpos($this->text, $str, $pos); 61 } 62 public function isAfterWhitespace($pos) 63 { 64 return ($pos > 0 && $this->isWhitespace($this->text[$pos - 1])); 65 } 66 public function isAlnum($chr) 67 { 68 return (\strpos(' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', $chr) > 0); 69 } 70 public function isBeforeWhitespace($pos) 71 { 72 return $this->isWhitespace($this->text[$pos + 1]); 73 } 74 public function isSurroundedByAlnum($pos, $len) 75 { 76 return ($pos > 0 && $this->isAlnum($this->text[$pos - 1]) && $this->isAlnum($this->text[$pos + $len])); 77 } 78 public function isWhitespace($chr) 79 { 80 return (\strpos(" \n\t", $chr) !== \false); 81 } 82 public function markBoundary($pos) 83 { 84 $this->text[$pos] = "\x17"; 85 } 86 public function overwrite($pos, $len) 87 { 88 if ($len > 0) 89 $this->text = \substr($this->text, 0, $pos) . \str_repeat("\x1A", $len) . \substr($this->text, $pos + $len); 90 } 91 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |