Page MenuHomePhabricator

SyntaxHighlight_GeSHi: Implement link anchors to line numbers of <source> contents
Open, LowPublic

Description

When we open a SVN page like this
http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/resources/Resources.php?revision=82285&view=markup#l142
we are able to add #l___ to the url to create links pointing to a specific part of the code.

On [[MediaWiki:Common.js]] and other [[*.js]] and [[*.css]] pages, there is no way to do this at the momment.

It would be great to have such a feature, mainly for long script pages.

Similarly, it would probably be desirable to display such line numbers in those js and css pages.


Version: unspecified
Severity: enhancement
URL: http://en.wikipedia.org/wiki/MediaWiki:Common.js

Details

Reference
bz27531

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 11:22 PM
bzimport set Reference to bz27531.
bzimport added a subscriber: Unknown Object (MLST).
He7d3r created this task.Feb 18 2011, 12:47 PM

Implementing that isn't difficult. implementing the syntax coloring code to work in accordance with that, is probably the more challenging issue.

FYI on code.google they use two columns, one for the line numbers and other for code. E.g.:

http://code.google.com/p/google-ajax-examples/source/browse/branches/javascript_playground/js/interactive_logic.js#2

TheDJ added a comment.Feb 18 2011, 1:11 PM

Checked, syntax extension does line based parsing as well, so less of a problem than I first thought.

(In reply to comment #3)

Checked, syntax extension does line based parsing as well, so less of a problem
than I first thought.

Yes, use <source line lang=...></source>. But ids per line are not added.

  • Bug 60410 has been marked as a duplicate of this bug. ***

gryllida wrote:

Is this a ::Parser bug? [[:mw:Extension:SyntaxHighlight_GeSHi]] seems to be responsible for <source> tag.

The output would probably use something like <span id="mw-source-f2-l31"> where f2 indicates it is the second <source> section on the page, and l31 line 31.

If handling potential multiple occurrences on a page is too difficult, we can at least start by supporting it on entire pages such as those in the MediaWiki and User namespaces for .js and .css.

Krinkle moved this task from Backlog to Accepted on the SyntaxHighlight board.Jun 25 2015, 10:33 PM

I do support this idea.

On single block pages, that might be simply #l1, #l2 as GIT does.

Those who like to make their line numbers addressable could use the id="exampleB" attribute, which creates #exampleB_1, #exampleB_2 identifiers.

WRT to the proposal above:

span id="mw-source-f2-l31" where f2 indicates it is the second <syntaxhighlight>## section on the page

Wiki pages are dynamic, not static nor frozen.

If I have a page with two examples

  1. id="exampleA" mapped to f1
  2. id="exampleB" mapped to f2

and someone inserts on top an explanation using <syntaxhighlight> or exampleA will be removed, then exampleB and its line numbers are supposed to be addressed as f3 or f1 from the outer world now.