Просмотр исходного кода

Merge branch 'master' of https://github.com/unaio/una

AntonLV 2 лет назад
Родитель
Сommit
6cde2c2d11
1 измененных файлов с 22 добавлено и 1 удалено
  1. 22 1
      inc/utils.inc.php

+ 22 - 1
inc/utils.inc.php

@@ -274,12 +274,33 @@ function bx_process_macros ($s)
     if (!bx_is_macros_in_content($s))
         return $s;
 
-    return preg_replace_callback(
+    $aCode = [];
+    $c1 = 1;
+
+    $s = preg_replace_callback(
+        "/<pre>(.*?)<\/pre>/s", 
+        function ($aMatches) use (&$c1, &$aCode) {
+            $aCode[$c1] = $aMatches[1];
+            return '<pre>___' . $c1++ . '___</pre>'; 
+        }, 
+        $s);
+
+    $s = preg_replace_callback(
         "/{{\~(.*?)\~}}/", 
         function ($aMatches) {
             return BxDolService::callMacro($aMatches[1]); 
         }, 
         $s);
+
+    $s = preg_replace_callback(
+        "/<pre>___(.*?)___<\/pre>/s", 
+        function ($aMatches) use (&$aCode) {
+            $sCode = isset($aCode[$aMatches[1]]) ? $aCode[$aMatches[1]] : 'n/a';
+            return '<pre>' . $sCode . '</pre>'; 
+        }, 
+        $s);
+
+    return $s;
 }
 
 /*