mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SyntaxHighlight_GeSHi
synced 2024-11-27 15:50:37 +00:00
Fix the case of empty <syntaxhighlight /> tags
Bug: T315740 Change-Id: I685806d4e8992a54f17d29a9187807bb30e31ef8
This commit is contained in:
parent
05bc73fd1f
commit
b08c0a7cb9
|
@ -109,7 +109,7 @@ class SyntaxHighlight extends ExtensionTagHandler {
|
|||
/**
|
||||
* Parser hook for <source> to add deprecated tracking category
|
||||
*
|
||||
* @param string $text
|
||||
* @param ?string $text
|
||||
* @param array $args
|
||||
* @param Parser $parser
|
||||
* @return string
|
||||
|
@ -162,7 +162,7 @@ class SyntaxHighlight extends ExtensionTagHandler {
|
|||
/**
|
||||
* Parser hook for both <source> and <syntaxhighlight> logic
|
||||
*
|
||||
* @param string $text
|
||||
* @param ?string $text
|
||||
* @param array $args
|
||||
* @param Parser $parser
|
||||
* @return string
|
||||
|
@ -170,7 +170,7 @@ class SyntaxHighlight extends ExtensionTagHandler {
|
|||
*/
|
||||
public static function parserHook( $text, $args, $parser ) {
|
||||
// Replace strip markers (For e.g. {{#tag:syntaxhighlight|<nowiki>...}})
|
||||
$out = $parser->getStripState()->unstripNoWiki( $text );
|
||||
$out = $parser->getStripState()->unstripNoWiki( $text ?? '' );
|
||||
|
||||
$result = self::processContent( $out, $args, $parser );
|
||||
foreach ( $result['cats'] as $cat ) {
|
||||
|
|
|
@ -169,6 +169,16 @@ Enclose with nowiki
|
|||
<p><code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr" about="#mwt1" typeof="mw:Extension/syntaxhighlight mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#tag:syntaxhighlight","function":"tag"},"params":{"1":{"wt":"<nowiki>foo</nowiki>"},"lang":{"wt":"\"text\""},"inline":{"wt":"none"}},"i":0}}]}'>foo</code></p>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
Self-closing tag
|
||||
!! options
|
||||
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
|
||||
!! wikitext
|
||||
<syntaxhighlight lang="CSharp" />
|
||||
!! html
|
||||
<div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"></div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
No code
|
||||
!! options
|
||||
|
|
Loading…
Reference in a new issue