MediaWiki  1.31.0
SyntaxHighlight.php File Reference

Go to the source code of this file.

Functions

static buildHeadItem ( $geshi)
 Backward-compatibility shim for extensions. More...
 
static getLexer ( $lang)
 Get the Pygments lexer name for a particular language. More...
 
static makeCacheKeyHash ( $code, $lexer, $options)
 Construct a cache key for the results of a Pygments invocation. More...
 
static onApiFormatHighlight (IContextSource $context, $text, $mime, $format)
 Hook to provide syntax highlighting for API pretty-printed output. More...
 
static onContentGetParserOutput (Content $content, Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output)
 Hook into Content::getParserOutput to provide syntax highlighting for script content. More...
 
static onParserFirstCallInit (Parser &$parser)
 Register parser hook. More...
 
static onResourceLoaderRegisterModules (&$resourceLoader)
 Conditionally register resource loader modules that depends on the VisualEditor MediaWiki extension. More...
 
static parseHighlightLines ( $lineSpec)
 Take an input specifying a list of lines to highlight, returning a raw list of matching line numbers. More...
 
static parserHook ( $text, $args, $parser)
 Parser hook. More...
 
static prepare ( $text, $lang)
 Backward-compatibility shim for extensions. More...
 
static validHighlightRange ( $start, $end)
 Validate a provided input range. More...
 

Variables

static array $mimeLexers
 Mapping of MIME-types to lexer names. More...
 
 $output = self::plainCodeWrap( $code, $inline )
 
return $status
 
class SyntaxHighlight startinline highlight highlight hl_lines start start linenostart start nowrap highlight l f html O
 
class SyntaxHighlight startinline highlight highlight hl_lines start start linenostart start nowrap highlight l f html syntaxhighlight error pygments invocation failure Failed to invoke Pygments
 
if( $inline) $status value = $output
 

Function Documentation

◆ buildHeadItem()

static buildHeadItem (   $geshi)
static

Backward-compatibility shim for extensions.

Deprecated:
since MW 1.25
Parameters
GeSHi$geshi
Returns
string

Definition at line 571 of file SyntaxHighlight.php.

References wfDeprecated().

◆ getLexer()

static getLexer (   $lang)
staticprivate

Get the Pygments lexer name for a particular language.

Parameters
string$langLanguage name.
Returns
string|null Lexer name, or null if no matching lexer.

Definition at line 345 of file SyntaxHighlight.php.

◆ makeCacheKeyHash()

static makeCacheKeyHash (   $code,
  $lexer,
  $options 
)
staticprivate

Construct a cache key for the results of a Pygments invocation.

Parameters
string$codeCode to be highlighted.
string$lexerLexer name.
array$optionsOptions array.
Returns
string Cache key.

Definition at line 361 of file SyntaxHighlight.php.

References $options, FormatJson\ALL_OK, and FormatJson\encode().

◆ onApiFormatHighlight()

static onApiFormatHighlight ( IContextSource  $context,
  $text,
  $mime,
  $format 
)
static

Hook to provide syntax highlighting for API pretty-printed output.

Parameters
IContextSource$context
string$text
string$mime
string$format
Since
MW 1.24
Returns
bool

Definition at line 485 of file SyntaxHighlight.php.

References $context, $mime, $mimeLexers, $out, and $output.

◆ onContentGetParserOutput()

static onContentGetParserOutput ( Content  $content,
Title  $title,
  $revId,
ParserOptions  $options,
  $generateHtml,
ParserOutput &  $output 
)
static

Hook into Content::getParserOutput to provide syntax highlighting for script content.

Parameters
Content$content
Title$title
int$revId
ParserOptions$options
bool$generateHtml
ParserOutput&$output
Returns
bool
Since
MW 1.21

Definition at line 429 of file SyntaxHighlight.php.

References $options, $out, $output, $title, $wgParser, $wgTextModelsToParse, ContentHandler\getContentText(), ExtensionRegistry\getInstance(), Content\getModel(), and global.

◆ onParserFirstCallInit()

static onParserFirstCallInit ( Parser &  $parser)
static

Register parser hook.

Parameters
Parser&$parser

Definition at line 381 of file SyntaxHighlight.php.

◆ onResourceLoaderRegisterModules()

static onResourceLoaderRegisterModules ( $resourceLoader)
static

Conditionally register resource loader modules that depends on the VisualEditor MediaWiki extension.

Parameters
ResourceLoader&$resourceLoader

Definition at line 517 of file SyntaxHighlight.php.

References $resourceLoader, class, and ExtensionRegistry\getInstance().

◆ parseHighlightLines()

static parseHighlightLines (   $lineSpec)
staticprotected

Take an input specifying a list of lines to highlight, returning a raw list of matching line numbers.

Input is comma-separated list of lines or line ranges.

Parameters
string$lineSpec
Returns
int[] Line numbers.

Definition at line 375 of file SyntaxHighlight.php.

References $lines, $value, and as.

◆ parserHook()

static parserHook (   $text,
  $args,
  $parser 
)
static

Parser hook.

Parameters
string$text
array$args
Parser$parser
Returns
string
Exceptions
MWException

Definition at line 396 of file SyntaxHighlight.php.

◆ prepare()

static prepare (   $text,
  $lang 
)
static

Backward-compatibility shim for extensions.

Deprecated:
since MW 1.25

Definition at line 560 of file SyntaxHighlight.php.

References $lang, and wfDeprecated().

◆ validHighlightRange()

static validHighlightRange (   $start,
  $end 
)
staticprotected

Validate a provided input range.

Parameters
int$start
int$end
Returns
bool

Definition at line 403 of file SyntaxHighlight.php.

Variable Documentation

◆ $mimeLexers

static array $mimeLexers
staticprivate
Initial value:
= [
'text/javascript' => 'javascript',
'application/json' => 'javascript',
'text/xml' => 'xml',
]

Mapping of MIME-types to lexer names.

Definition at line 333 of file SyntaxHighlight.php.

Referenced by onApiFormatHighlight().

◆ $output

$output = self::plainCodeWrap( $code, $inline )

Definition at line 338 of file SyntaxHighlight.php.

Referenced by Maintenance\activateProfiler(), ProtectionForm\buildForm(), WikiExporter\closeStream(), StringUtils\delimiterReplaceCallback(), LinkHolderArray\doVariants(), CodeEditorHooks\editPageShowEditFormInitial(), SpecialRenameuser\execute(), SpecialContributions\execute(), SpecialExpandTemplates\execute(), SpecialWatchlist\execute(), CategoryTreePage\execute(), SpecialEditTags\execute(), SpecialRevisionDelete\execute(), DumpCategoriesAsRdf\execute(), BlockLevelPass\execute(), SpecialPageExecutor\executeSpecialPage(), GadgetDefinitionContent\fillParserOutput(), JsonContent\fillParserOutput(), DummyNonTextContent\fillParserOutput(), DummyContentForTesting\fillParserOutput(), TextContent\fillParserOutput(), WikitextContent\fillParserOutput(), ExecutableFinder\findExecutable(), MediaWiki\Logger\Monolog\LineFormatter\format(), AutoloadGenerator\generatePHPAutoload(), CategoryMembershipChangeJob\getCategoriesAtRev(), TextContentHandler\getDataForSearchIndex(), ContentHandler\getDataForSearchIndex(), SpecialPageExecutor\getHTMLFromSpecialPage(), ChangesListStringOptionsFilterGroup\getJsData(), ChangesListBooleanFilter\getJsData(), ChangesListFilterGroup\getJsData(), ChangesListFilter\getJsData(), WebInstallerLanguage\getLanguageSelector(), EditPage\getPreviewLimitReport(), ChangesListSpecialPage\getStructuredFilterJsData(), PageDataRequestHandler\handleRequest(), DumpRenderer\handleRevision(), CryptHKDF\HKDFExpand(), PageDataRequestHandler\httpContentNegotiation(), StringUtils\hungryDelimiterReplace(), Profiler\logData(), Profiler\logDataPageOutputOnly(), MediaWiki\main(), SpecialExpandTemplates\makeOutput(), PageDataRequestHandlerTest\makeOutputPage(), Maintenance\maybeHelp(), mccGetHelp(), onApiFormatHighlight(), onContentGetParserOutput(), InputBoxHooks\onMediaWikiPerformAction(), SpamBlacklistHooks\onParserOutputStashForEdit(), SpamBlacklistHooks\onUploadVerifyUpload(), ImagePage\openShowImage(), WikiExporter\openStream(), SpecialWatchlist\outputChangesList(), WikiExporter\outputLogStream(), WikiExporter\outputPageStream(), InfoAction\pageInfo(), MediaWiki\performAction(), MediaWiki\performRequest(), Wikimedia\Rdbms\DatabasePostgres\pg_array_parse(), MediaWiki\preOutputCommit(), ParserTestPrinter\quickDiff(), SectionProfiler\remapCallTree(), ImageMap\render(), LinkHolderArray\replaceInternal(), LinkHolderArray\replaceInterwiki(), UserNotLoggedIn\report(), SpecialAllPages\showChunk(), SpecialGadgets\showExportForm(), UserrightsPage\showLogFragment(), SpecialGadgets\showMainForm(), SpecialPrefixindex\showPrefixChunk(), SpecialEditWatchlist\showTitles(), JpegHandler\swapICCProfile(), BalancerTest\testBalancer(), WfShellExecTest\testBug67870(), FirejailCommandTest\testBuildFinalCommand(), DatabaseMysqlBaseTest\testBuildIntegerCast(), DatabaseSQLTest\testBuildIntegerCast(), DatabaseOracleTest\testBuildSubstring(), DatabaseMssqlTest\testBuildSubstring(), DatabaseSqliteRdbmsTest\testBuildSubstring(), DatabaseSQLTest\testBuildSubstring(), ListToggleTest\testConstruct(), ContentHandlerTest\testDataIndexFields(), SpecialPageDataTest\testExecute(), ArrayDiffFormatterTest\testFormat(), FormatMetadataTest\testGetFormattedData(), ListToggleTest\testGetHTML(), BaseBlacklistTest\testGetTypeFromTitle(), PageDataRequestHandlerTest\testHandleRequest(), PageDataRequestHandlerTest\testHttpContentNegotiation(), WfTimestampTest\testHttpDate(), MediaWiki\Tests\Storage\SlotRecordTest\testNewWithSuppressedContent(), WfTimestampTest\testNormalTimestamps(), WfTimestampTest\testOldTimestamps(), JpegPixelFormatTest\testPixelFormatRendering(), PreprocessorTest\testPreprocessorOutputFiles(), LocalisationUpdate\UpdaterTest\testReadMessages(), FormatMetadataTest\testResolveMultivalueValue(), SpecialPageDataTest\testSpecialPageWithoutParameters(), CommandTest\testT69870(), ApiResultTest\testTransformations(), AbstractChangesListSpecialPageTestCase\testValidateOptions(), WfAssembleUrlTest\testWfAssembleUrl(), WfShorthandToIntegerTest\testWfShorthandToInteger(), TraditionalImageGallery\toHTML(), MediaWiki\tryNormaliseRedirect(), wfArrayInsertAfter(), wfRemoveDotSegments(), and GenerateJqueryMsgData\writeJavascriptFile().

◆ $status

return $status

Definition at line 350 of file SyntaxHighlight.php.

◆ O

class SyntaxHighlight startinline highlight highlight hl_lines start start linenostart start nowrap highlight l f html O

Definition at line 21 of file SyntaxHighlight.php.

◆ Pygments

class SyntaxHighlight startinline highlight highlight hl_lines start start linenostart start nowrap highlight l f html syntaxhighlight error pygments invocation failure Failed to invoke Pygments

Definition at line 21 of file SyntaxHighlight.php.

◆ value