diff --git a/include/text.php b/include/text.php index d251824e2b..97baee7f60 100644 --- a/include/text.php +++ b/include/text.php @@ -1911,58 +1911,3 @@ function format_network_name($network, $url = 0) { return $network_name; } } - -/** - * @brief Syntax based code highlighting for popular languages. - * @param string $s Code block - * @param string $lang Programming language - * @return string Formated html - */ -function text_highlight($s, $lang) { - if ($lang === 'js') { - $lang = 'javascript'; - } - - if ($lang === 'bash') { - $lang = 'sh'; - } - - // @TODO: Replace Text_Highlighter_Renderer_Html by scrivo/highlight.php - - // Autoload the library to make constants available - class_exists('Text_Highlighter_Renderer_Html'); - - $options = [ - 'numbers' => HL_NUMBERS_LI, - 'tabsize' => 4, - ]; - - $tag_added = false; - $s = trim(html_entity_decode($s, ENT_COMPAT)); - $s = str_replace(' ', "\t", $s); - - /* - * The highlighter library insists on an opening php tag for php code blocks. If - * it isn't present, nothing is highlighted. So we're going to see if it's present. - * If not, we'll add it, and then quietly remove it after we get the processed output back. - */ - if ($lang === 'php' && strpos($s, 'factory($lang); - $hl->setRenderer($renderer); - $o = $hl->highlight($s); - $o = str_replace("\n", '', $o); - - if ($tag_added) { - $b = substr($o, 0, strpos($o, '
  • ')); - $e = substr($o, strpos($o, '
  • ')); - $o = $b . $e; - } - - return '' . $o . ''; -} diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index ef527f802c..b403b1f349 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1164,21 +1164,6 @@ class BBCode extends BaseObject return $return; } - private static function textHighlightCallback($match) - { - // Fallback in case the language doesn't exist - $return = '[code]' . $match[2] . '[/code]'; - - if (in_array(strtolower($match[1]), - ['php', 'css', 'mysql', 'sql', 'abap', 'diff', 'html', 'perl', 'ruby', - 'vbscript', 'avrc', 'dtd', 'java', 'xml', 'cpp', 'python', 'javascript', 'js', 'sh', 'bash']) - ) { - $return = text_highlight($match[2], strtolower($match[1])); - } - - return $return; - } - /** * @brief Converts a BBCode message to HTML message *