Ejemplo n.º 1
0
 public static function safeLongText($string)
 {
     check_condition($string, 'Пустое сообщение');
     $texExtractor = TexExtractor::inst($string, true);
     $string = $texExtractor->getMaskedText();
     $string = htmlspecialchars($string);
     $string = nl2brr($string);
     $string = $texExtractor->restoreMasks($string);
     /*
      * Удалим двойные пробелы, т.к. к этом моменту уже все переносы 
      * строк заменены на <br />
      */
     return normalize_string($string);
 }
Ejemplo n.º 2
0
 /**
  * Извлекает формулы из переданного текста.
  * Возвращает коолекцию TEX->DirItem
  */
 public function extractTexImages($string, $createIfNotExists = true, $addDescr = false)
 {
     $formules = array();
     foreach (TexExtractor::inst($string, true)->getTexContents() as $formula) {
         $di = $this->getImgDi($formula, $createIfNotExists);
         if (!$di) {
             continue;
         }
         $formules[$formula] = $di;
         if (!$addDescr) {
             continue;
         }
         $formules["{$formula}.tex"] = DirItem::inst(null, $di->getAbsPath(), '.tex');
     }
     return $formules;
 }