Extension:SyntaxHighlight/ru

Extension:SyntaxHighlight GeSHi прозволяет форматировать исходный код source code с подсветкой синтаксиса.

Это расширение добавляет окраску в зависимости от настройки кода на языке. Like the  tags and the   tags, the tags shows the coding exactly as it was typed, preserving white space.

Это расширение позваляет также нумеровать строки.

source tag replaced
Before 50696, the  tag was used. It is still supported, but  is recommended to avoid possible conflicts. The original syntax is used in some other languages, e.g. XML.

Использование
На вики странице Вы можете использовать элемент - "syntaxhighlight". Записанное на вике странице так:

Будет выглядеть так:

Альтернативные тэги
это также используется внекторых других языках (например XML). Если Вашь код содержит поддерживается. рекомендуется избегать конфликтов, упомянутых выше.

Параметры

 * Определяет какой язык программирования в исходном коде используется. Это влияет на расширение подсветки исходного кода. Смотри здесь "Supported languages" в этой странице для подробностей поддерживаемого исходного кода.
 * Определяет какой язык программирования в исходном коде используется. Это влияет на расширение подсветки исходного кода. Смотри здесь "Supported languages" в этой странице для подробностей поддерживаемого исходного кода.


 * Type of line numbering to use (default is no line numbering). Corresponds to enable_line_numbers the flag in GeSHi.
 * Type of line numbering to use (default is no line numbering). Corresponds to enable_line_numbers the flag in GeSHi.


 * Use together with the parameter "line". Define the start number of the line. If you type line start="55", it will start counting at 55, then 56,57,58... and so on. Corresponds to start_line_numbers_at method on GeSHi
 * Use together with the parameter "line". Define the start number of the line. If you type line start="55", it will start counting at 55, then 56,57,58... and so on. Corresponds to start_line_numbers_at method on GeSHi


 * Specifies which line is highlighted. Note that the parameter line start="??" doesn't affect how it counts the lines.
 * Specifies which line is highlighted. Note that the parameter line start="??" doesn't affect how it counts the lines.


 * Specifies what container is used to enclose the source code. Takes values "pre" (default value), "div", "none". Corresponds to set_header_type method on GeSHi. Choosing "div" will cause text to wrap, which is helpful if text is extending off the edge of the screen, causing horizontal scrolling.
 * Specifies what container is used to enclose the source code. Takes values "pre" (default value), "div", "none". Corresponds to set_header_type method on GeSHi. Choosing "div" will cause text to wrap, which is helpful if text is extending off the edge of the screen, causing horizontal scrolling.


 * Type the name of the parameter to enable the strict mode. Corresponds to enable_strict_mode method on GeSHi.
 * Type the name of the parameter to enable the strict mode. Corresponds to enable_strict_mode method on GeSHi.

The effect and usage of these parameters can be consulted in GeSHi's documentation.

Since r22246, you can override the colors using MediaWiki:Geshi.css.

Дополнительные возможности
When line numbering is added with line, long code lines will be wrapped. See the example below. When text is the selected language, and numbering is used, the behaviour resembles the use of pre tags with numbering and long-line wrapping.

The following example shows how to color an HTML code listing: A typical result is just:

Поддерживаемые языки
These are the languages known by GeSHi that can be used in the lang parameter.

Note that installed GeSHi version (can be revealed by previewing e.g. ) might not be the most recent version;  see 10967 for Wikimedia sites.

Язык исходного кода по умолчанию
Added in 50693.

If the site mainly quotes the source code of a specific programming language, it would be helpful to set a default language.

To do so, add a new variable to LocalSettings.php, just after the require_once line. We set C programming language as an example:

Шаг 1: Загрузка

 * Method 1: Manual downloading with snapshot

Click on the snapshot link, also above

Alternatively, click on the extension's Subversion repository. Open each of the 4 file's pages, and download the files by opening and saving the pages behind the download link. Save (or upload) these files into the extensions/SyntaxHighlight_GeSHi directory of your wiki.
 * Method 2: Manual downloading with subversion

Next, go to the GeSHi project site and download the latest stable release. Unpack (and upload) these files into the extensions/SyntaxHighlight_GeSHi/geshi directory of your wiki.

Notes:
 * GeSHi 1.1.2alpha3 does not work with the MediaWiki extension.
 * You need both the MediaWiki extension files and the GeSHi project files from SourceForge to make it work!
 * You can delete the extensions/SyntaxHighlight_GeSHi/geshi/docs directory to save a few megabytes.


 * Method 3: Already bundled with subversion (SVN)

Since r46666, we bundle Geshi into subversion. When downloading via the ExtensionDistributor or directly from SVN, there should already be a "geshi" directory inside your SyntaxHighlight_GeSHi directory. If this is the case then GeSHi is already installed.


 * Method 4: Using an SVN tool

Use an SVN tool to checkout http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/SyntaxHighlight_GeSHi/.

For example using the SVN command-line tool:

This will automatically also download the latest stable version of GeSHi.

Save (or upload) everything into the extensions/SyntaxHighlight_GeSHi directory of your wiki.

Note: You can delete the extensions/SyntaxHighlight_GeSHi/geshi/docs directory and the various .svn directories to save a few megabytes.

You can also use the SVN command-line tool to download the latest stable version without all the .svn directories. This will save you having to find and remove each of them.

Шаг 2: Установка
Добавьте следующую строку в Ваш LocalSettings.php:


 * Установка GeSHi ( если не помогло )

Способ 1
Если Вы не установили GeSHi в каталог extensions/SyntaxHighlight_GeSHi/geshi, тогда измените следующую строку SyntaxHighlight_GeSHi.class.php</tt> в соответствии с путём к файлу geshi.php

Способ 2
Иногда вам нужно будет добавить абсолютный путь к geshi (/var/www/html/.../geshi/geshi.php)

Способ 3
Использования функцию PHP dirname с глобальной постоянной __FILE__ :

Настройка
Если вы хотите пунктирную границы как для   </tt> тегов вы должны добавить их снова.

Метод 1: CSS файл

 * Этот метод требует это расширение ревизии r52346 или выше

Добавте MediaWiki:Geshi.css, MediaWiki:Monobook.css или MediaWiki:Common.css страницам:

Это даст всем GeSHi output (за исключением enclose="none"</tt>) апунктирные границы почти идентичны &lt;pre&gt; в monobook/main.css

Метод 2: Встроенные CSS
You can also edit the SyntaxHighlight_GeSHi.class.php around line 215 (Line 264 in SVN trunk 82481). Look for this: and change it to: On a Unix-like system simply type this command in the directory containing "SyntaxHighlight_GeSHi.class.php": Link to Extension Talk (2008): Extension talk:SyntaxHighlight GeSHi/Archive 2008
 * See also 52346.


 * If you already add the extension to LocalSettings.php before changing this, comment it out via "#" and refresh the page, then remove the # and refresh one more time.

Метод 3. По умолчанию: основанное на DIV отображение
Long strings will cause the page width to blow up when rendered on a web page. The solution to this is to use the enclose="div" tag, this can be enabled by default by editing SyntaxHighlight_GeSHi.class.php near line 156. Look for the following: and append a else case to the if statement:

Баги и ограничения
''None so far. You may report bugs by clicking here.''

См. также

 * GeSHiCodeTag - A working alternative extension that also uses Geshi
 * GeSHi - Generic Syntax Highlighter
 * ASHighlight (MediaWiki support for Andre Simon's highlight utility)
 * Extension:Geshi includes every component - no additional downloads
 * Extension:Include -- yet another source code syntax highlighter
 * Extension:SyntaxHighlight_GeSHi_ParserFunction -- Parser function based alternative, can be used with Semantic MediaWiki
 * Extension:GoogleCodePrettify - syntax highlighter that uses Google Code Prettify library.
 * Extension:SyntaxHighlighter - syntax highlighter that uses SyntaxHighlighter library.