Last modified: 2014-02-07 12:05:41 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 13644 - Add automatic line numbering capability to <poem> tag
Add automatic line numbering capability to <poem> tag
Status: ASSIGNED
Product: MediaWiki extensions
Classification: Unclassified
Poem (Other open bugs)
unspecified
All All
: Low enhancement with 6 votes (vote)
: Future release
Assigned To: This, that and the other (TTO)
:
Depends on:
Blocks: Wikisource
  Show dependency treegraph
 
Reported: 2008-04-07 15:07 UTC by Tyler Romeo
Modified: 2014-02-07 12:05 UTC (History)
7 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Tyler Romeo 2008-04-07 15:07:10 UTC
In certain texts, mostly plays, parts of the text are referred to by Act number, Scene number, and Line number. It would be helpful if MediaWiki had an option (mainly for use in WikiSource) where line numbers are inserted to the left of the text.
Comment 1 Steve Sanbeg 2008-04-07 16:58:41 UTC
There is an option to add a number to every line, i.e. with something like:

<source lang=text line=normal>
some text
</source>

If more control is needed over the formatting, it might make sense to add more functionality to the poem extension.
Comment 2 Jesse (Pathoschild) 2008-04-07 17:27:02 UTC
Would a CSS-like declaration be feasible? Something like <poem options="compact; line-numbers;" />, or <poem options="compact; line-numbers:5;" /> (only label every 5th line).

This would be a very good feature of <poem>, but it should not be default. <poem> is used generically for maintaining whitespace, not only for poems.
Comment 3 Steve Sanbeg 2008-04-07 18:28:36 UTC
It would be easier to parse separate options, since the parser will take care of that, and pass an associative array to the extension.  i.e. something like <poem compact line-numbers=5>
Comment 4 Jesse (Pathoschild) 2008-04-09 00:35:04 UTC
For consistency with other wiki syntax, would it be just as easy to parse HTML-like syntax (like <poem line-numbers="5">)?
Comment 5 Jesse (Pathoschild) 2008-04-09 00:36:04 UTC
(For other parameters like compact too, I mean.)
Comment 6 Steve Sanbeg 2008-04-09 15:50:00 UTC
Yes, the parser will parse HTML-like syntax before calling the extension, so it would be consistent with other wiki tags.  
Comment 7 Candalua 2013-06-20 10:10:32 UTC
Any updates on this? I think it would be a very useful feature, not only for Wikisource but wherever poem is used. 

I imagine adding these parameters to the tag poem:
* start: the number from which to start (default 1)
* step: the interval between numbers (example: 5, default: don't put any number, to be compatible with the current usage). It could be a number, or could be also one of these special values:
** step="stanzas" -> number the stanzas instead of the lines (showing the number on each first line of each stanza)
** step="lastline" -> put the number on every last line of each stanza (useful for sonnets)
Comment 8 Alessandro Brollo 2013-06-25 09:51:33 UTC
Here a more "elastic" test solution  in Lua (it's not intended for use, but to explore algorithms only): http://it.wikisource.org/wiki/Modulo:Poem

The trick is to wrap verses produced by poem extension into span tags, and to add parameters into such span; in out it.wikisource test implementation we added a id attribute, a title attribute and a class attribute; all contain the verse number, calculated by Lua script, so obtaining an anchor to link any verse by id, a box with verse number when pointing the mouse, and various jQuery tricks to filter verses (and to produce different verse number display you like without changing wikicode).
Comment 9 This, that and the other (TTO) 2014-01-27 10:32:42 UTC
I will submit a patch for MediaWiki core once bug 52061 is resolved.

The implementation/syntax I propose is as follows:

    <poem number-start=1
          number-step=5
          number-show-first
          number-class="fancyLetters">

- Start and step are as per comment 7, although I prefer "first" and "last"
  (or "stanza-first" and "stanza-last") instead of "stanzas" and "lastline".
  The default for both is 1.

- number-show-first can be optionally specified if you want e.g.
  lines 1, 6, 11, 16... to be numbered, instead of the default 5, 10, 15...

- number-class is optional CSS class(es) to be applied to the line numbers.

To enable line numbering, you simply specify any one of these attributes.

Each line number would get an anchor (e.g. #5, #10). Lines without a visible number get no anchor, to avoid excessive HTML clutter.

Feedback is welcome :)
Comment 10 Candalua 2014-01-27 11:20:44 UTC
(In reply to comment #9)

Good news, thanks! :) My comments:

- "stanza-first" and "stanza-last" are OK to me, but it seems stanza-first will do something different from the "stanzas" which I proposed. As I understand, "stanza-first" will just count every line, and show the number only on the lines which are the first of their stanza, eg.: 1, 9, 17, 25... My "stanzas" proposal was to count each stanza as 1 and show the number of the stanza, not the number of the line, eg: 1, 2, 3, 4... Of course this is not "one or the other" :), I think both possibilities are useful and should be implemented (maybe also at a later time, the most important thing for now is to have the "basic" numbering system with number-start and a numeric number-step).

- On bug 52061, comment 21, they suggested the possibility of assigning a custom css class to poem. If this is done, maybe number-class is not required: you can give all numbers a standard class "line-number", then users can give a custom class to poem, like "fancyPoem", and they can define the behavior using css subclass like ".fancyPoem .line-number {...}"

- I would favour giving anchors to all lines. This would make it much easier to link to a specific line. Otherwise I'm sure that people would resort to linking to the "closest line" :D, which is not desirable. I'm not sure if it's better to use #line5, #line10 instead of #5, #10, since in HTML4 ids are required to start with a letter (although most browsers tolerate that - also HTML5 is more permissive about that).
Comment 11 This, that and the other (TTO) 2014-01-27 11:35:51 UTC
(In reply to comment #10)
> As I understand,
> "stanza-first" will just count every line, and show the number only on the
> lines which are the first of their stanza, eg.: 1, 9, 17, 25... My "stanzas"
> proposal was to count each stanza as 1 and show the number of the stanza, not
> the number of the line, eg: 1, 2, 3, 4... Of course this is not "one or the
> other" :), I think both possibilities are useful and should be implemented
> (maybe also at a later time, the most important thing for now is to have the
> "basic" numbering system with number-start and a numeric number-step).

Good point about stanza counting.

Numbering first/last lines of stanzas is turning out to be more difficult to code than I thought. I'll see what I can do. For now, I've got the basic numeric functionality to work correctly, which is a good start.

> - On bug 52061, comment 21, they suggested the possibility of assigning a
> custom css class to poem. If this is done, maybe number-class is not
> required:
> you can give all numbers a standard class "line-number", then users can give
> a
> custom class to poem, like "fancyPoem", and they can define the behavior
> using
> css subclass like ".fancyPoem .line-number {...}"

What would actually be more useful than number-class, now I think about it, is a "number-style" attribute, allowing ad hoc styling of line numbers for an individual poem (not otherwise possible without editing global CSS files).

> - I would favour giving anchors to all lines. This would make it much easier
> to
> link to a specific line. Otherwise I'm sure that people would resort to
> linking
> to the "closest line" :D, which is not desirable. I'm not sure if it's better
> to use #line5, #line10 instead of #5, #10, since in HTML4 ids are required to
> start with a letter (although most browsers tolerate that - also HTML5 is
> more
> permissive about that).

OK, makes sense. By the way, MediaWiki outputs HTML5 now, so numeric anchors should not be an issue. Browsers don't seem to choke on them, although older ones like IE6 would have to be checked.
Comment 12 Ricordisamoa 2014-02-07 12:05:41 UTC
For lines, a compromise could be #l5, #l10, etc.: that would also allow to assign #s1, #s2, etc. to stanzas, thus supporting anchors to lines while displaying the stanzas count only.

But most importantly, the software should check for repeated (non-unique) ids, that would make the HTML invalid, potentially breaking the achor functionality.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links