![]() |
![]() |
ВходЗдравствуйте, Гость ( Вход | Регистрация )
|
![]() ![]() |
![]() |
![]()
Сообщение
#1
|
|
x_X ![]() Группа: Дизайнеры Сообщений: 633 Регистрация: 12.4.2008 Из: :( Украина :( Пользователь №: 3,219 Спасибо сказали: 229 Вставить ник ![]() |
Скачать скрипт ![]() Распаковать и загрузить папку highlight из архива в папку ./jscripts/ форума Загрузить файл highlight.css ![]() из архива мода в папку ./style_images/имя_папки_скина/ форума. ПРОДЕЛАТЬ ДЛЯ ВСЕХ ПАПОК СКИНОВ В ./style_images/ Во всех скинах в глобальном шаблоне найти: КОД <% CSS %> Добавить после: КОД <!--(SnS) SoftwareManiacs highlighter--> <link type="text/css" rel="stylesheet" href="style_images/<#IMG_DIR#>/highlight.css"></link> <!--(SnS) SoftwareManiacs highlighter /--> Во всех скинах в шаблоне skin_global->global_board_header добавить в самый конец: КОД <!--(SnS) SoftwareManiacs highlighter--> <script type="text/javascript" src="jscripts/highlight/highlight.js"></script> <script type="text/javascript"> //<![CDATA[ hljs.initHighlightingOnLoad(); //]]> </script> <!--(SnS) SoftwareManiacs highlighter /--> Открыть файл ./jscripts/ipb_topic.js, найти: КОД document.getElementById( 'post-'+post_id ).innerHTML = html; xmlobj.execute_javascript( html ); fix_linked_image_sizes(); Добавить после: КОД // (SnS) SoftwareManiacs highlighter hljs.initHighlighting(); // (SnS) SoftwareManiacs highlighter [E] Открыть файл ./jscripts/ips_profile_portal.js, найти: КОД //----------------------------------------- // Topic attachment sizes... //----------------------------------------- try { fix_linked_image_sizes(); xmlobj.execute_javascript( html ); Добавить после: КОД // (SnS) SoftwareManiacs highlighter hljs.initHighlighting(); // (SnS) SoftwareManiacs highlighter [E] Заходим в Админцентр -> Управление -> Добавить BB-код: Название: Код с подсветкой Пример использования: [code=php]$show = $this->_getUrlLocalName('members', $match[1]);[/code] Тег: code Использовать опции в теге?: Да. Поменять option и content местами?: Нет. Шаблон замены BB-кода: <pre><code class="{option}">{content}</code></pre> Добавить в меню «Теги» редактора?: По вашему усмотрению. Подсказка для 'option': Язык подсветки Подсказка для 'content': Подсвечиваемый код Добавить! Открыть файл ./sources/classes/bbcode/class_bbcode.php, найти: ЦИТАТА //----------------------------------------- // Do КОД tag ', $txt );//----------------------------------------- $txt = preg_replace_callback( "#\[code\](.+?)\[/code\]#is", array( &$this, 'regex_code_tag' ), $txt );[/quote] [b]Заменить на:[/b] [quote]//-------------------------------------- // (SnS) SoftwareManiacs highlighter //-------------------------------------- $txt = preg_replace( "#\[code\s*=\s*(?:\"\;|\")\s*([^\]]+)\s*(?:\"\;|\")\s*\](.+?)\[/code\]#ies" , "\$this->regex_highlight_code(array('lang' => '\\1', 'code' => '\\2'))", $txt ); $txt = preg_replace( "#\[code\s*=\s*([^\]]+)\s*\](.+?)\[/code\]#ies" , "\$this->regex_highlight_code(array('lang' => '\\1', 'code' => '\\2'))", $txt ); $txt = preg_replace( "#\[code\](.+?)\[/code\]#ies" , "\$this->regex_highlight_code(array('lang' => 'no-highlight', 'code' => '\\1'))", $txt ); // (SnS) SoftwareManiacs highlighter [E][/quote] [b]Найти:[/b] [quote]//----------------------------------------- // CODE //----------------------------------------- $txt = preg_replace( "#<!--c1-->(.+?)<!--ec1-->#", '[code]' , $txt ); $txt = preg_replace( "#<!--c2-->(.+?)<!--ec2-->#", ' Заменить на: ЦИТАТА //-------------------------------------- // (SnS) SoftwareManiacs highlighter //-------------------------------------- $txt = preg_replace( "#<!--shcode--><pre><code class='([^']+)'>#", '[code=\\1]' , $txt ); $txt = str_replace( "[code=no]", ' КОД ' , $txt ); ' , $txt );$txt = str_replace( "</code></pre><!--ehcode-->", ' // Old code fragments $txt = preg_replace( "#<!--c1-->(.+?)<!--ec1-->#", ' КОД ' , $txt ); ', $txt );$txt = preg_replace( "#<!--c2-->(.+?)<!--ec2-->#", ' // (SnS) SoftwareManiacs highlighter [E] Открыть файл ./sources/classes/bbcode/class_bbcode_legacy.php, найти: ЦИТАТА //----------------------------------------- // Do КОД tag ', $txt );//----------------------------------------- $txt = preg_replace( "#\[code\](.+?)\[/code\]#ies", "\$this->regex_code_tag( '\\1' )", $txt );[/quote] [b]Заменить на:[/b] [quote]//-------------------------------------- // (SnS) SoftwareManiacs highlighter //-------------------------------------- $txt = preg_replace( "#\[code\s*=\s*(?:\"\;|\")\s*([^\]]+)\s*(?:\"\;|\")\s*\](.+?)\[/code\]#ies" , "\$this->regex_highlight_code(array('lang' => '\\1', 'code' => '\\2'))", $txt ); $txt = preg_replace( "#\[code\s*=\s*([^\]]+)\s*\](.+?)\[/code\]#ies" , "\$this->regex_highlight_code(array('lang' => '\\1', 'code' => '\\2'))", $txt ); $txt = preg_replace( "#\[code\](.+?)\[/code\]#ies" , "\$this->regex_highlight_code(array('lang' => 'no-highlight', 'code' => '\\1'))", $txt ); // (SnS) SoftwareManiacs highlighter [E][/quote] [b]Найти:[/b] [quote]//----------------------------------------- // CODE //----------------------------------------- $txt = preg_replace( "#<!--c1-->(.+?)<!--ec1-->#", '[code]' , $txt ); $txt = preg_replace( "#<!--c2-->(.+?)<!--ec2-->#", ' Заменить на: ЦИТАТА //-------------------------------------- // (SnS) SoftwareManiacs highlighter //-------------------------------------- $txt = preg_replace( "#<!--shcode--><pre><code class='([^']+)'>#", '[code=\\1]' , $txt ); $txt = str_replace( "[code=no]", ' КОД ' , $txt ); ' , $txt );$txt = str_replace( "</code></pre><!--ehcode-->", ' // Old code fragments $txt = preg_replace( "#<!--c1-->(.+?)<!--ec1-->#", ' КОД ' , $txt ); ', $txt );$txt = preg_replace( "#<!--c2-->(.+?)<!--ec2-->#", ' // (SnS) SoftwareManiacs highlighter [E] Открыть файл ./sources/classes/bbcode/class_bbcode_core.php, найти: ЦИТАТА /*-------------------------------------------------------------------------*/ // regex_code_tag: Builds this code tag HTML /*-------------------------------------------------------------------------*/ /** * Build code tag, make contents safe * * @param string Raw text * @return string Converted text */ function regex_code_tag( $matches=array() ) Добавить перед: ЦИТАТА /** * (SnS) SoftwareManiacs highlighter * Build highlighted code, make contents safe * * @param string Raw text * @return string Converted text */ function regex_highlight_code( $matches=array() ) { //----------------------------------------- // We don't want to trim indentations on the first line //----------------------------------------- $code = rtrim( $matches['code'] ); $lang = trim ( $matches['lang'] ); $code = preg_replace( "#^(\n+)(.+?)$#s", "\\2", $code ); if ( $code == "" ) { return; } //----------------------------------------- // Take a stab at removing most of the common // smilie characters. //----------------------------------------- //$txt = str_replace( "&" , "&", $txt ); $code = str_replace( "<" , "<" , $code ); $code = str_replace( ">" , ">" , $code ); $code = str_replace( "<" , "<" , $code ); $code = str_replace( ">" , ">" , $code ); $code = str_replace( """ , """ , $code ); $code = str_replace( ":" , ":" , $code ); $code = str_replace( "[" , "[" , $code ); $code = str_replace( "]" , "]" , $code ); $code = str_replace( ")" , ")" , $code ); $code = str_replace( "(" , "(" , $code ); $code = str_replace( "\r" , "<br />", $code ); $code = str_replace( "\n" , "<br />", $code ); $code = preg_replace( "#\s{1};#" , ";" , $code); //----------------------------------------- // Ensure that spacing is preserved //----------------------------------------- $code = preg_replace( "#\t#" , " ", $code ); $code = preg_replace( "#\s{2}#", " " , $code ); return "<!--shcode--><pre><code class='{$lang}'>{$code}</code></pre><!--ehcode-->"; } Открыть файл ./jscripts/highlight/highlight.js, найти: КОД function initHighlighting() { if (initHighlighting.called) return; initHighlighting.called = true; compileModes(); compileKeywords(); if (arguments.length) { for (var i = 0; i < arguments.length; i++) { if (LANGUAGES[arguments[i]]) { selected_languages[arguments[i]] = LANGUAGES[arguments[i]]; } } } else selected_languages = LANGUAGES; var pres = document.getElementsByTagName('pre'); for (var i = 0; i < pres.length; i++) { if (pres[i].firstChild && pres[i].firstChild.nodeName == 'CODE') highlightBlock(pres[i].firstChild); } } Заменить на: КОД function initHighlighting() { if (!initHighlighting.called) { initHighlighting.called = true; compileModes(); compileKeywords(); if (arguments.length) { for (var i = 0; i < arguments.length; i++) { if (LANGUAGES[arguments[i]]) { selected_languages[arguments[i]] = LANGUAGES[arguments[i]]; } } } else selected_languages = LANGUAGES; } var pres = document.getElementsByTagName('pre'); for (var i = 0; i < pres.length; i++) { if (pres[i].firstChild && pres[i].firstChild.nodeName == 'CODE') highlightBlock(pres[i].firstChild); } } this.initHighlighting = initHighlighting; Всё! © Sannis По скольку с тэгами форума и с переменными [ code ] &[ /code] возникают проблемы отображения,выкладываю оригинальный файл,дабы не запутаться...
Прикрепленные файлы
|
Z1dan3, Вас 1 раз(а) поблагодарили за это сообщение: ATIX | |
|
|
![]() ![]() |
![]() |
Текстовая версия | Сейчас: 25 April 2025 - 19:22 |