Debian Codegraph @

extensions/SyntaxHighlight_GeSHi/includes/SyntaxHighlight.php

raw symbols SCIP
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 */
18
19 namespace MediaWiki\SyntaxHighlight;
20
21 use MediaWiki\Api\Hook\ApiFormatHighlightHook;
22 use MediaWiki\Content\Content;
23 use MediaWiki\Content\Hook\ContentGetParserOutputHook;
24 use MediaWiki\Content\TextContent;
25 use MediaWiki\Context\IContextSource;
26 use MediaWiki\Hook\ParserFirstCallInitHook;
27 use MediaWiki\Hook\SoftwareInfoHook;
28 use MediaWiki\Html\Html;
29 use MediaWiki\Json\FormatJson;
30 use MediaWiki\MainConfigNames;
31 use MediaWiki\MediaWikiServices;
32 use MediaWiki\Parser\Parser;
33 use MediaWiki\Parser\ParserOptions;
34 use MediaWiki\Parser\ParserOutput;
35 use MediaWiki\Parser\Sanitizer;
36 use MediaWiki\Registration\ExtensionRegistry;
37 use MediaWiki\ResourceLoader\Hook\ResourceLoaderRegisterModulesHook;
38 use MediaWiki\ResourceLoader\ResourceLoader;
39 use MediaWiki\Status\Status;
40 use MediaWiki\Title\Title;
41 use RuntimeException;
42 use Wikimedia\ObjectCache\WANObjectCache;
43 use Wikimedia\Parsoid\Core\ContentMetadataCollectorStringSets as CMCSS;
44 use Wikimedia\Parsoid\DOM\DocumentFragment;
45 use Wikimedia\Parsoid\Ext\ExtensionTagHandler;
46 use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
47
48 class SyntaxHighlight extends ExtensionTagHandler implements
49 ParserFirstCallInitHook,
50 ContentGetParserOutputHook,
51 ResourceLoaderRegisterModulesHook,
52 ApiFormatHighlightHook,
53 SoftwareInfoHook
54 {
55
56 /** @var string CSS class for syntax-highlighted code. Public as used by the updateCSS maintenance script. */
57 public const HIGHLIGHT_CSS_CLASS = 'mw-highlight';
58
59 /** @var int Cache version. Increment whenever the HTML changes. */
60 private const CACHE_VERSION = 2;
61
62 /** @var array<string,string> Mapping of MIME-types to lexer names. */
63 private static $mimeLexers = [
64 'text/javascript' => 'javascript',
65 'application/json' => 'javascript',
66 'text/xml' => 'xml',
67 ];
68
69 /**
70 * Returns the maximum number of lines that may be selected for highlighting
71 *
72 * @return int
73 */
74 private static function getMaxLines(): int {
75 $config = MediaWikiServices::getInstance()->getMainConfig();
76 return $config->get( 'SyntaxHighlightMaxLines' );
77 }
78
79 /**
80 * Returns the maximum input size for the highlighter
81 *
82 * @return int
83 */
84 private static function getMaxBytes(): int {
85 $config = MediaWikiServices::getInstance()->getMainConfig();
86 return $config->get( 'SyntaxHighlightMaxBytes' );
87 }
88
89 /**
90 * Get the Pygments lexer name for a particular language.
91 *
92 * @param string|null $lang Language name.
93 * @return string|null Lexer name, or null if no matching lexer.
94 */
95 private static function getLexer( $lang ) {
96 static $lexers = null;
97
98 if ( $lang === null ) {
99 return null;
100 }
101
102 $lexers ??= Pygmentize::getLexers();
103
104 $lexer = strtolower( $lang );
105
106 if ( isset( $lexers[$lexer] ) ) {
107 return $lexer;
108 }
109
110 $geshi2pygments = SyntaxHighlightGeSHiCompat::getGeSHiToPygmentsMap();
111
112 // Check if this is a GeSHi lexer name for which there exists
113 // a compatible Pygments lexer with a different name.
114 if ( isset( $geshi2pygments[$lexer] ) ) {
115 $lexer = $geshi2pygments[$lexer];
116 if ( isset( $lexers[$lexer] ) ) {
117 return $lexer;
118 }
119 }
120
121 return null;
122 }
123
124 /**
125 * Register parser hook
126 *
127 * @param Parser $parser
128 */
129 public function onParserFirstCallInit( $parser ) {
130 $parser->setHook( 'source', [ self::class, 'parserHookSource' ] );
131 $parser->setHook( 'syntaxhighlight', [ self::class, 'parserHook' ] );
132 }
133
134 /**
135 * Parser hook for <source> to add deprecated tracking category
136 *
137 * @param ?string $text
138 * @param array $args
139 * @param Parser $parser
140 * @return string
141 */
142 public static function parserHookSource( $text, $args, $parser ) {
143 $parser->addTrackingCategory( 'syntaxhighlight-source-category' );
144 return self::parserHook( $text, $args, $parser );
145 }
146
147 /**
148 * @return string[]
149 */
150 private static function getModuleStyles(): array {
151 return [ 'ext.pygments' ];
152 }
153
154 /**
155 *
156 * @param string $text
157 * @param array $args
158 * @param ?Parser $parser
159 * @return array
160 */
161 private static function processContent( string $text, array $args, ?Parser $parser = null ): array {
162 // Don't trim leading spaces away, just the linefeeds
163 $out = rtrim( trim( $text, "\n" ) );
164 $trackingCats = [];
165
166 // Convert deprecated attributes
167 if ( isset( $args['enclose'] ) ) {
168 if ( $args['enclose'] === 'none' ) {
169 $args['inline'] = true;
170 }
171 unset( $args['enclose'] );
172 $trackingCats[] = 'syntaxhighlight-enclose-category';
173 }
174
175 $lexer = $args['lang'] ?? '';
176
177 $result = self::highlight( $out, $lexer, $args, $parser );
178 if ( !$result->isGood() ) {
179 $trackingCats[] = 'syntaxhighlight-error-category';
180 }
181
182 return [ 'html' => $result->getValue(), 'cats' => $trackingCats ];
183 }
184
185 /**
186 * Parser hook for both <source> and <syntaxhighlight> logic
187 *
188 * @param ?string $text
189 * @param array $args
190 * @param Parser $parser
191 * @return string
192 */
193 public static function parserHook( $text, $args, $parser ) {
194 // Replace strip markers (For e.g. {{#tag:syntaxhighlight|<nowiki>...}})
195 $out = $parser->getStripState()->unstripNoWiki( $text ?? '' );
196
197 $result = self::processContent( $out, $args, $parser );
198 foreach ( $result['cats'] as $cat ) {
199 $parser->addTrackingCategory( $cat );
200 }
201
202 // Register modules
203 $parser->getOutput()->addModuleStyles( self::getModuleStyles() );
204 $parser->getOutput()->addModules( [ 'ext.pygments.view' ] );
205 return $result['html'];
206 }
207
208 /** @inheritDoc */
209 public function sourceToDom(
210 ParsoidExtensionAPI $extApi, string $text, array $extArgs
211 ): ?DocumentFragment {
212 $result = self::processContent( $text, $extApi->extArgsToArray( $extArgs ) );
213
214 // FIXME: There is no API method in Parsoid to add tracking categories
215 // So, $result['cats'] is being ignored
216
217 // Register modules
218 $extApi->getMetadata()->appendOutputStrings( CMCSS::MODULE_STYLE, self::getModuleStyles() );
219 $extApi->getMetadata()->appendOutputStrings( CMCSS::MODULE, [ 'ext.pygments.view' ] );
220
221 return $extApi->htmlToDom( $result['html'] );
222 }
223
224 /**
225 * Unwrap the <div> wrapper of the Pygments output
226 *
227 * @param string $out Output
228 * @return string Unwrapped output
229 */
230 private static function unwrap( string $out ): string {
231 if ( $out !== '' ) {
232 $m = [];
233 if ( preg_match( '/^<div class="?mw-highlight"?>(.*)<\/div>$/s', trim( $out ), $m ) ) {
234 $out = trim( $m[1] );
235 } else {
236 throw new RuntimeException( 'Unexpected output from Pygments encountered' );
237 }
238 }
239 return $out;
240 }
241
242 /**
243 * @param string $code
244 * @param bool $isInline
245 * @return string HTML
246 */
247 private static function plainCodeWrap( $code, $isInline ) {
248 if ( $isInline ) {
249 return htmlspecialchars( $code, ENT_NOQUOTES );
250 }
251
252 return Html::rawElement(
253 'div',
254 [ 'class' => self::HIGHLIGHT_CSS_CLASS ],
255 Html::element( 'pre', [], $code )
256 );
257 }
258
259 /**
260 * @param string $code
261 * @param string|null $lang
262 * @param array $args
263 * @param Parser|null $parser Parser, if generating content to be parsed.
264 * @return Status
265 */
266 private static function highlightInner( $code, $lang = null, $args = [], ?Parser $parser = null ) {
267 $status = new Status;
268
269 $lexer = self::getLexer( $lang );
270 if ( $lexer === null && $lang !== null ) {
271 $status->warning( 'syntaxhighlight-error-unknown-language', $lang );
272 }
273
274 // For empty tag, output nothing instead of empty <pre>.
275 if ( $code === '' ) {
276 $status->value = '';
277 return $status;
278 }
279
280 $length = strlen( $code );
281 if ( strlen( $code ) > self::getMaxBytes() ) {
282 // Disable syntax highlighting
283 $lexer = null;
284 $status->warning(
285 'syntaxhighlight-error-exceeds-size-limit',
286 $length,
287 self::getMaxBytes()
288 );
289 }
290
291 $isInline = isset( $args['inline'] );
292 $showLines = isset( $args['line'] );
293
294 if ( $isInline ) {
295 $code = trim( $code );
296 }
297
298 if ( $lexer === null ) {
299 // When syntax highlighting is disabled..
300 $status->value = self::plainCodeWrap( $code, $isInline );
301 return $status;
302 }
303
304 if ( $parser && !$parser->incrementExpensiveFunctionCount() ) {
305 // Highlighting is expensive, return unstyled
306 $status->value = self::plainCodeWrap( $code, $isInline );
307 return $status;
308 }
309
310 $options = [
311 'cssclass' => self::HIGHLIGHT_CSS_CLASS,
312 'encoding' => 'utf-8',
313 ];
314
315 // Line numbers
316 if ( $showLines ) {
317 $options['linenos'] = 'inline';
318 }
319
320 if ( $lexer === 'php' && strpos( $code, '<?php' ) === false ) {
321 $options['startinline'] = 1;
322 }
323
324 // Highlight specific lines
325 if ( isset( $args['highlight'] ) ) {
326 $lines = self::parseHighlightLines( $args['highlight'] );
327 if ( count( $lines ) ) {
328 $options['hl_lines'] = implode( ' ', $lines );
329 }
330 }
331
332 // Starting line number
333 if ( isset( $args['start'] ) && ctype_digit( $args['start'] ) ) {
334 $options['linenostart'] = (int)$args['start'];
335 }
336
337 if (
338 !empty( $args['linelinks'] )
339 // Protect against injecting arbitrary Pygmentize options, as those are separated with commas
340 && !str_contains( $args['linelinks'], ',' )
341 ) {
342 $options['linespans'] = htmlspecialchars( $args['linelinks'] );
343 }
344
345 if ( $isInline ) {
346 $options['nowrap'] = 1;
347 }
348
349 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
350 $error = null;
351 $output = $cache->getWithSetCallback(
352 $cache->makeGlobalKey( 'highlight', self::makeCacheKeyHash( $code, $lexer, $options ) ),
353 $cache::TTL_MONTH,
354 static function ( $oldValue, &$ttl ) use ( $code, $lexer, $options, &$error ) {
355 try {
356 return Pygmentize::highlight( $lexer, $code, $options );
357 } catch ( PygmentsException $e ) {
358 $ttl = WANObjectCache::TTL_UNCACHEABLE;
359 $error = $e->getMessage();
360 return null;
361 }
362 }
363 );
364
365 if ( $error !== null || $output === null ) {
366 $status->warning( 'syntaxhighlight-error-pygments-invocation-failure' );
367 if ( $error !== null ) {
368 wfWarn( 'Failed to invoke Pygments: ' . $error );
369 } else {
370 wfWarn( 'Invoking Pygments returned blank output with no error response' );
371 }
372
373 // Fall back to preformatted code without syntax highlighting
374 $output = self::plainCodeWrap( $code, $isInline );
375 }
376
377 $status->value = $output;
378
379 return $status;
380 }
381
382 /**
383 * Highlight a code-block using a particular lexer.
384 *
385 * This produces raw HTML (wrapped by Status), the caller is responsible
386 * for making sure the "ext.pygments" module is loaded in the output.
387 *
388 * @param string $code Code to highlight.
389 * @param string|null $lang Language name, or null to use plain markup.
390 * @param array $args Associative array of additional arguments.
391 * If it contains a 'line' key, the output will include line numbers.
392 * If it includes a 'highlight' key, the value will be parsed as a
393 * comma-separated list of lines and line-ranges to highlight.
394 * If it contains a 'start' key, the value will be used as the line at which to
395 * start highlighting.
396 * If it contains a 'inline' key, the output will not be wrapped in `<div><pre/></div>`.
397 * If it contains a 'linelinks' key, lines will have links and anchors with a prefix
398 * of the value. Similar to the lineanchors+linespans features in Pygments.
399 * If it contains a 'copy' key, a link will be shown for copying content to the clipboard.
400 * @param Parser|null $parser Parser, if generating content to be parsed.
401 * @return Status Status object, with HTML representing the highlighted
402 * code as its value.
403 */
404 public static function highlight( $code, $lang = null, $args = [], ?Parser $parser = null ) {
405 $status = self::highlightInner( $code, $lang, $args, $parser );
406 $output = $status->getValue();
407
408 $isInline = isset( $args['inline'] );
409 $showLines = isset( $args['line'] );
410 $lexer = self::getLexer( $lang );
411
412 // Post-Pygment HTML transformations.
413
414 if ( $showLines ) {
415 $lineReplace = Html::element( 'span', [ 'class' => 'linenos', 'data-line' => '$1' ] );
416 if ( !empty( $args['linelinks'] ) ) {
417 $lineReplace = Html::rawElement(
418 'a',
419 [ 'href' => '#' . $args['linelinks'] . '-$1' ],
420 $lineReplace
421 );
422 }
423 // Convert line numbers to data attributes so they
424 // can be displayed as CSS generated content and be
425 // unselectable in all browsers.
426 $output = preg_replace(
427 '`<span class="linenos">\s*([^<]*)\s*</span>`',
428 $lineReplace,
429 $output
430 );
431 }
432
433 // Allow certain HTML attributes
434 $htmlAttribs = Sanitizer::validateAttributes(
435 $args, array_flip( [ 'style', 'class', 'id' ] )
436 );
437
438 $dir = ( isset( $args['dir'] ) && $args['dir'] === 'rtl' ) ? 'rtl' : 'ltr';
439
440 // Build class list
441 $classList = [];
442 if ( isset( $htmlAttribs['class'] ) ) {
443 $classList[] = $htmlAttribs['class'];
444 }
445 $classList[] = self::HIGHLIGHT_CSS_CLASS;
446 if ( $lexer !== null ) {
447 $classList[] = self::HIGHLIGHT_CSS_CLASS . '-lang-' . $lexer;
448 }
449 $classList[] = 'mw-content-' . $dir;
450 if ( $showLines ) {
451 $classList[] = self::HIGHLIGHT_CSS_CLASS . '-lines';
452 }
453 if ( !$isInline && isset( $args['copy'] ) ) {
454 $classList[] = 'mw-highlight-copy';
455 }
456 $htmlAttribs['class'] = implode( ' ', $classList );
457 $htmlAttribs['dir'] = $dir;
458 '@phan-var array{class:string,dir:string} $htmlAttribs';
459
460 if ( $isInline ) {
461 // We've already trimmed the input $code before highlighting,
462 // but pygment's standard out adds a line break afterwards,
463 // which would then be preserved in the paragraph that wraps this,
464 // and become visible as a space. Avoid that.
465 $output = trim( $output );
466
467 // Enforce inlineness. Stray newlines may result in unexpected list and paragraph processing
468 // (also known as doBlockLevels()).
469 $output = str_replace( "\n", ' ', $output );
470 $output = Html::rawElement( 'code', $htmlAttribs, $output );
471 } else {
472 $output = self::unwrap( $output );
473
474 if ( $parser ) {
475 // Use 'nowiki' strip marker to prevent list processing (also known as doBlockLevels()).
476 // However, leave the wrapping <div/> outside to prevent <p/>-wrapping.
477 $marker = $parser::MARKER_PREFIX . '-syntaxhighlightinner-' .
478 sprintf( '%08X', $parser->mMarkerIndex++ ) . $parser::MARKER_SUFFIX;
479 $parser->getStripState()->addNoWiki( $marker, $output );
480 $output = $marker;
481 }
482
483 $output = Html::openElement( 'div', $htmlAttribs ) .
484 $output .
485 Html::closeElement( 'div' );
486 }
487
488 $status->value = $output;
489 return $status;
490 }
491
492 /**
493 * Construct a cache key for the results of a Pygments invocation.
494 *
495 * @param string $code Code to be highlighted.
496 * @param string $lexer Lexer name.
497 * @param array $options Options array.
498 * @return string Cache key.
499 */
500 private static function makeCacheKeyHash( $code, $lexer, $options ) {
501 $optionString = FormatJson::encode( $options, false, FormatJson::ALL_OK );
502 return md5( "{$code}|{$lexer}|{$optionString}|" . self::CACHE_VERSION );
503 }
504
505 /**
506 * Take an input specifying a list of lines to highlight, returning
507 * a raw list of matching line numbers.
508 *
509 * Input is comma-separated list of lines or line ranges.
510 *
511 * @param string $lineSpec
512 * @return int[] Line numbers.
513 */
514 protected static function parseHighlightLines( $lineSpec ) {
515 $lines = [];
516 $values = array_map( 'trim', explode( ',', $lineSpec ) );
517 foreach ( $values as $value ) {
518 if ( ctype_digit( $value ) ) {
519 $lines[] = (int)$value;
520 } elseif ( strpos( $value, '-' ) !== false ) {
521 [ $start, $end ] = array_map( 'intval', explode( '-', $value ) );
522 if ( self::validHighlightRange( $start, $end ) ) {
523 for ( $i = $start; $i <= $end; $i++ ) {
524 $lines[] = $i;
525 }
526 }
527 }
528 if ( count( $lines ) > self::getMaxLines() ) {
529 $lines = array_slice( $lines, 0, self::getMaxLines() );
530 break;
531 }
532 }
533 return $lines;
534 }
535
536 /**
537 * Validate a provided input range
538 * @param int $start
539 * @param int $end
540 * @return bool
541 */
542 protected static function validHighlightRange( $start, $end ) {
543 // Since we're taking this tiny range and producing a an
544 // array of every integer between them, it would be trivial
545 // to DoS the system by asking for a huge range.
546 // Impose an arbitrary limit on the number of lines in a
547 // given range to reduce the impact.
548 return $start > 0 &&
549 $start < $end &&
550 $end - $start < self::getMaxLines();
551 }
552
553 /**
554 * Hook into Content::getParserOutput to provide syntax highlighting for
555 * script content.
556 *
557 * @param Content $content
558 * @param Title $title
559 * @param int $revId
560 * @param ParserOptions $options
561 * @param bool $generateHtml
562 * @param ParserOutput &$parserOutput
563 * @return bool
564 * @since MW 1.21
565 */
566 public function onContentGetParserOutput( $content, $title,
567 $revId, $options, $generateHtml, &$parserOutput
568 ) {
569 // Hope that the "SyntaxHighlightModels" attribute does not contain silly types.
570 if ( !( $content instanceof TextContent ) ) {
571 // Oops! Non-text content? Let MediaWiki handle this.
572 return true;
573 }
574
575 if ( !$generateHtml ) {
576 // Nothing special for us to do, let MediaWiki handle this.
577 return true;
578 }
579
580 // Determine the SyntaxHighlight language from the page's
581 // content model. Extensions can extend the default CSS/JS
582 // mapping by setting the SyntaxHighlightModels attribute.
583 $extension = ExtensionRegistry::getInstance();
584 $models = $extension->getAttribute( 'SyntaxHighlightModels' ) + [
585 CONTENT_MODEL_CSS => 'css',
586 CONTENT_MODEL_JAVASCRIPT => 'javascript',
587 ];
588 $model = $content->getModel();
589 if ( !isset( $models[$model] ) ) {
590 // We don't care about this model, carry on.
591 return true;
592 }
593 $lexer = $models[$model];
594 $text = $content->getText();
595
596 $config = MediaWikiServices::getInstance()->getMainConfig();
597 // Parse using the standard parser to get links etc. into the database, HTML is replaced below.
598 // We could do this using $content->fillParserOutput(), but alas it is 'protected'.
599 if ( in_array( $model, $config->get( MainConfigNames::TextModelsToParse ), true ) ) {
600 $parserOutput = MediaWikiServices::getInstance()->getParser()
601 ->parse( $text, $title, $options, true, true, $revId );
602 }
603
604 $status = self::highlight( $text, $lexer, [ 'line' => true, 'linelinks' => 'L' ] );
605 if ( !$status->isOK() ) {
606 return true;
607 }
608 $out = $status->getValue();
609
610 $parserOutput->addModuleStyles( self::getModuleStyles() );
611 $parserOutput->addModules( [ 'ext.pygments.view' ] );
612 $parserOutput->setText( $out );
613
614 // Inform MediaWiki that we have parsed this page and it shouldn't mess with it.
615 return false;
616 }
617
618 /**
619 * Hook to provide syntax highlighting for API pretty-printed output
620 *
621 * @param IContextSource $context
622 * @param string $text
623 * @param string $mime
624 * @param string $format
625 * @since MW 1.24
626 * @return bool
627 */
628 public function onApiFormatHighlight( $context, $text, $mime, $format ) {
629 if ( !isset( self::$mimeLexers[$mime] ) ) {
630 return true;
631 }
632
633 $lexer = self::$mimeLexers[$mime];
634 $status = self::highlight( $text, $lexer );
635 if ( !$status->isOK() ) {
636 return true;
637 }
638
639 $out = $status->getValue();
640 if ( preg_match( '/^<pre([^>]*)>/i', $out, $m ) ) {
641 $attrs = Sanitizer::decodeTagAttributes( $m[1] );
642 $attrs['class'] .= ' api-pretty-content';
643 $encodedAttrs = Sanitizer::safeEncodeTagAttributes( $attrs );
644 $out = '<pre' . $encodedAttrs . '>' . substr( $out, strlen( $m[0] ) );
645 }
646 $output = $context->getOutput();
647 $output->addModuleStyles( self::getModuleStyles() );
648 $output->addHTML( '<div dir="ltr">' . $out . '</div>' );
649
650 // Inform MediaWiki that we have parsed this page and it shouldn't mess with it.
651 return false;
652 }
653
654 /**
655 * Hook to add Pygments version to Special:Version
656 *
657 * @see https://www.mediawiki.org/wiki/Manual:Hooks/SoftwareInfo
658 * @param array &$software
659 */
660 public function onSoftwareInfo( &$software ) {
661 try {
662 $software['[https://pygments.org/ Pygments]'] = Pygmentize::getVersion();
663 } catch ( PygmentsException $e ) {
664 // pass
665 }
666 }
667
668 /**
669 * Hook to register ext.pygments.view module.
670 * @param ResourceLoader $rl
671 */
672 public function onResourceLoaderRegisterModules( ResourceLoader $rl ): void {
673 $rl->register( 'ext.pygments.view', [
674 'localBasePath' => MW_INSTALL_PATH . '/extensions/SyntaxHighlight_GeSHi/modules',
675 'remoteExtPath' => 'SyntaxHighlight_GeSHi/modules',
676 'scripts' => array_merge( [
677 'pygments.linenumbers.js',
678 'pygments.links.js',
679 'pygments.copy.js'
680 ], ExtensionRegistry::getInstance()->isLoaded( 'Scribunto' ) ? [
681 'pygments.links.scribunto.js'
682 ] : [] ),
683 'styles' => [
684 'pygments.copy.less'
685 ],
686 'messages' => [
687 'syntaxhighlight-button-copy',
688 'syntaxhighlight-button-copied'
689 ],
690 'dependencies' => [
691 'mediawiki.util',
692 'mediawiki.Title'
693 ]
694 ] );
695 }
696 }