Page MenuHomePhabricator

Support ignoring the line attribute when attribute "line" set to "off" (or 0)
Open, LowestPublic

Description

motivation:
I would like to create a template that (among other things) calls syntaxhighlight via parser function {{#tag}}.

unfortunately neither
{{#tag:syntaxhighlight|{{{code|{{{2}}}}}}|lang="{{{lang|{{{1|text}}}}}}"|start="{{{start|1}}}"|highlight="{{{highlight|}}}"|{{#if:{{{line|}}}|line=1}}
nor
{{#tag:syntaxhighlight|{{{code|{{{2}}}}}}|lang="{{{lang|{{{1|text}}}}}}"|start="{{{start|1}}}"|highlight="{{{highlight|}}}"{{#if:{{{line|}}}{{!}}line=1}}
works

With the litte patch suggest below, something like this is possible (works perfekt):
{{#tag:syntaxhighlight|{{{code|{{{2}}}}}}|lang="{{{lang|{{{1|text}}}}}}"|start="{{{start|1}}}"|highlight="{{{highlight|}}}"|line="{{{line|on}}}"}}

So my request:
Does anyone have a solution to the problem. Otherwise, could you please consider the following alteration:

// Line numbers
if( isset( $args['line'] ) && $args['line'] != 'off' )
  $geshi->enable_line_numbers( GESHI_FANCY_LINE_NUMBERS );
}

regards,
Tobias

Event Timeline

Oetterer raised the priority of this task from to Lowest.
Oetterer updated the task description. (Show Details)
Oetterer added a subscriber: Oetterer.
Oetterer set Security to None.
Oetterer renamed this task from ignore line attribute when attribute "line" set to 0 to ignore line attribute when attribute "line" set to off (or 0).Oct 2 2015, 3:00 PM

Hi @Oetterer. This does not sound like something is wrong in the code of MediaWiki (a so-called "bug"), but instead like a support request (how to change settings, questions how to do something, etc.). As Wikimedia Phabricator/Maniphest is only for specific reports and enhancement requests, please use the MediaWiki Support Desk for support requests. Thanks!

Oetterer renamed this task from ignore line attribute when attribute "line" set to off (or 0) to ignore line attribute when attribute "line" set to "off" (or 0).Oct 2 2015, 3:00 PM

ah, ok, sorry. thought, this could be used to post feature request. will do, thanks for the advise!

Aklapper renamed this task from ignore line attribute when attribute "line" set to "off" (or 0) to Support ignoring the line attribute when attribute "line" set to "off" (or 0).Oct 2 2015, 5:36 PM

The entire problem space has moved, as Wikimedia now uses Pygments. @Oetterer , are you still using the syntax highlighter that uses GeSHi ?

Specifically testme whether line=off, line=false, line=disabled or some other reasonable boolean like value is possible.
IMO line=0 is not a good option.

I've just retested this task.

By using mediawiki-vagrant:
MediaWiki 1.31.0-alpha (827c6bf) 23:57, 5 January 2018
SyntaxHighlight 2.0 (578bb79) 11:38, 2 January 2018

Step to reproduce:

  1. Create a page in mediawiki.
  2. Write these wikitext to test:
# These should add the number, but they don't
{{#tag:syntaxhighlight|{{{code|{{{2}}}}}}|lang="{{{lang|{{{1|text}}}}}}"|start="{{{start|1}}}"|highlight="{{{highlight|}}}"|{{#if:true|line=1}}}}
{{#tag:syntaxhighlight|{{{code|{{{2}}}}}}|lang="{{{lang|{{{1|text}}}}}}"|start="{{{start|1}}}"|highlight="{{{highlight|}}}"|{{#if: | | line=1}}}}

Yeah these are still not work in the current SyntaxHighlight extension:

{{#tag:syntaxhighlight|{{{code|{{{2}}}}}}|lang="{{{lang|{{{1|text}}}}}}"|start="{{{start|1}}}"|highlight="{{{highlight|}}}"|{{#if:{{{line|}}}|line=1}}}}

{{#tag:syntaxhighlight|{{{code|{{{2}}}}}}|lang="{{{lang|{{{1|text}}}}}}"|start="{{{start|1}}}"|highlight="{{{highlight|}}}"|{{#if:{{{line|}}}{{!}}line=1}}}}

I also have tried some new combinations and still not work:

# These should add the number, but they don't
{{#tag:syntaxhighlight|{{{code|{{{2}}}}}}|lang="{{{lang|{{{1|text}}}}}}"|start="{{{start|1}}}"|highlight="{{{highlight|}}}"|{{#if:true|line=1}}}}
{{#tag:syntaxhighlight|{{{code|{{{2}}}}}}|lang="{{{lang|{{{1|text}}}}}}"|start="{{{start|1}}}"|highlight="{{{highlight|}}}"|{{#if: | | line=1}}}}

{{#tag:syntaxhighlight|{{{code|{{{2}}}}}}|lang="{{{lang|{{{1|text}}}}}}"|start="{{{start|1}}}"|highlight="{{{highlight|}}}"|line=0}}

{{#tag:syntaxhighlight|{{{code|{{{2}}}}}}|lang="{{{lang|{{{1|text}}}}}}"|start="{{{start|1}}}"|highlight="{{{highlight|}}}"|line=null}}

{{#tag:syntaxhighlight|{{{code|{{{2}}}}}}|lang="{{{lang|{{{1|text}}}}}}"|start="{{{start|1}}}"|highlight="{{{highlight|}}}"|line=false}}

Because the SyntaxHighlight extension still just detects if the line key exists or not, so whatever the value in line parameter, it will still enable the line option:

		// Line numbers
		if ( isset( $args['line'] ) ) {
			$options['linenos'] = 'inline';
		}

So if we want to disable the line option, we need to delete the line parameter in the SyntaxHighlight tag, I think it's not possible by using {{#if: | | }} syntax in the SyntaxHighlight wikitext tag.

A patch to SyntaxHighglight seems reasonable for this..

The entire problem space has moved, as Wikimedia now uses Pygments. @Oetterer , are you still using the syntax highlighter that uses GeSHi ?

As I see it, the problem is independant of the underlying engine, or am I missing something? 8/