Commit graph

3139 commits

Author SHA1 Message Date
jenkins-bot a8e882e39f Merge "Show "Preview" headline in user instead of content language" 2019-12-09 10:13:17 +00:00
jenkins-bot 3b41cfa472 Merge "Fail early on nested extends="…", if possible" 2019-12-09 10:12:54 +00:00
jenkins-bot 399a9c63bf Merge "Numbering bug: Parser test which should fail" 2019-12-09 10:06:06 +00:00
Thiemo Kreuz c5fe49ff11 Fail early on nested extends="…", if possible
This partly reverts Ied2e3f5. I haven't properly tested this before.
Rendering a bad extends (that extends a <ref> that's already extended)
not indented messes the order up and rips other extended <ref>s out of
context.

For now it might be better to stick to the previous, "magic" behavior:
Such an extends behaves like it is extending the *parent*, and is
ordered and indented as such. This is still not correct, but I feel
this is much better than rendering such a bad extends on the top level.

This patch also makes the code fail much earlier for a nested extends,
if this decision can be made already. In this case the error message is
rendered in the middle of the text (as other errors also are), not in
the <references> section.

Change-Id: I33c6a763cd6c11df09d10dfab73f955ed15e9d36
2019-12-09 10:54:52 +01:00
Thiemo Kreuz 8fdce945bd Show "Preview" headline in user instead of content language
This partly reverts Id7a4036e64920acdeccb4dfcf6bef31d0e5657ab.

The message "cite_section_preview_references" says "Preview of references".
This line is not meant to be part of the content, but an interface message.
It should use the users (interface) language, not the content language.

Change-Id: I1b1b5106266606eb0dfaa31f4abd3cee9ba92e8c
2019-12-09 10:53:07 +01:00
jenkins-bot 238ed31d2e Merge "Add fail-safe default branch to switch-case" 2019-12-09 09:52:41 +00:00
jenkins-bot dfee9cc254 Merge "Add missing dot to "1.2." list numbering for extended refs" 2019-12-09 09:50:50 +00:00
jenkins-bot 08dc662861 Merge "Fix broken reference list numbering in Firefox" 2019-12-09 09:47:42 +00:00
Adam Wight a91cf43154 Remove outdated TODOs
These edge cases are handled correctly already, I just forgot to
remove the TODOs when updating test content.

Note that there's only one TODO left, and it's to forbid a feature which
actually works!

Change-Id: I0d3a1f55f0ce943b0d034dda40e3779fbf241fe4
2019-12-09 10:25:19 +01:00
Thiemo Kreuz d18c0871a8 Fix broken reference list numbering in Firefox
Same as Ib6e9de6.

We must reset the build-in "list-item" counter to make this code behave
sane in Firefox. It looks like this is even described in the CSS spec
and it is not Firefox having a bug, but Chrome being "clever" and not
following the spec.

Bug: T229307
Change-Id: I955786e2b68d087c819a962ded3c571946c61f78
2019-12-09 10:10:54 +01:00
Thiemo Kreuz fc1865780d Add missing dot to "1.2." list numbering for extended refs
All mock screenshots on
https://de.wikipedia.org/wiki/Wikipedia:Technische_W%C3%BCnsche/Topw%C3%BCnsche/Erweiterung_der_Einzelnachweise
show this extra dot.

Note the numbering scheme "1." and "1.1" (without the dot) was not a
mistake. It's not uncommon to only have the extra dot on the first
level.

However, I feel the scheme "1." and "1.1." might be a little more
consistent and less surprising.

Change-Id: I0dc467755926f82d88a48fb7594af0bde8bbee21
2019-12-09 09:55:32 +01:00
Adam Wight d8433101a7 Numbering bug: Parser test which should fail
Includes the TODO for what correct output looks like.

Bug: T237241
Change-Id: I0e60724f2c418b19e5affc24dca7f446c2b38bb3
2019-12-09 09:53:53 +01:00
Translation updater bot f0d964260d Localisation updates from https://translatewiki.net.
Change-Id: I288c44b26a18d3fa46e9f71b6b5f7509bcd1fc1b
2019-12-09 09:33:57 +01:00
Thiemo Kreuz a7ee7c9586 Refine and fix "unclosed <ref> detected" regular expression
This simplifies as well as fixes a series of issues with this regular
expression:

* Before, the wikitext `<REF><REF>` would not trigger the error, but
`<ref><ref>` would. Parser tags are case-insensitive, but the error
check was not.

* Before, the wikitext `<ref><ref name="<">` would not trigger the error.
That's a valid name. The error check should not stop just because it
found a `<`.

* Both the old and the new code do *not* fail with the wikitext
`<ref><ref</ref>` where the inner `<ref` does not have a closing `>`. I
was thinking about changing this, but figured it might be used as a
feature.

* The old code was not able to properly understand HTML comments,
<nowiki> tags and such that contain a line break. That caused
inconsistent and confusing error reporting in some cases, but not in
others. This change *reduces* the amount of errors this code produces.

* The old code was looking for "SGML tags" with names that could be
anything, not just alphanumeric characters. This allowed for strange
edge-cases like `<ref><>><ref></>></ref>` that have not been reported,
but should be. This change *increases* the amount of errors. However,
relevant edge-cases should be extremely rare.

Note the ++ avoids backtracking, speeding up the regex.

Change-Id: I0c61a245f4f743871b4cad886ce239650af2b37c
2019-12-08 04:37:13 +00:00
jenkins-bot 07a54bbe69 Merge "Narrow message localizer interface" 2019-12-07 16:14:13 +00:00
Thiemo Kreuz 92312b4421 Add fail-safe default branch to switch-case
Reported as a possible code-smell at sonarcloud.io.

Change-Id: I3c5c1ff116dabe06c3d2e3cc59850ad3c66f8f83
2019-12-06 14:30:40 +01:00
Adam Wight 484205c7b5 Shorten description for Special:Version
Naming the tag is consistent with other extensions.  Going into detail
about specific attributes or closing the XML tag is unnecessary.

Change-Id: I0c81707222fcf18d12a313d4d3973bf77848eddd
2019-12-06 14:12:20 +01:00
Adam Wight 3d80501829 Narrow message localizer interface
We never access Language directly, so proxy its method instead of
returning the full object.

I believe I've found a bug, but not fixing here: the footnote body
numeric backlinks like "2.1" behave as if they were decimals rather
than two numbers stuck together with a dot.  So they are localized
to "2,1".

Bug: T239725
Change-Id: If386bf96d48cb95c0a287a02bedfe984941efe30
2019-12-06 12:17:09 +01:00
Translation updater bot a3c589ac42 Localisation updates from https://translatewiki.net.
Change-Id: I55a4fa4edb32bd6b7df74083bd278aea5573f760
2019-12-06 09:29:33 +01:00
jenkins-bot f745a6b2f2 Merge "Roll up a range in test fixture" 2019-12-05 14:50:29 +00:00
jenkins-bot 9622c4fb8f Merge "Comments to help understand the message localizer" 2019-12-05 14:49:58 +00:00
Adam Wight 01c76f46a6 Use message localizer in CiteKeyFormatter
Makes more tests easier.

Change-Id: I222ba61bfcf0be3e29cb04e39f44f0be7a9e0778
2019-12-05 14:57:32 +01:00
Adam Wight 1ce4079ce2 Use message localizer in FootnoteMarkFormatter
Completes test coverage.

Change-Id: Ib2ec24cf4a9de52769744d1888cb13d2bf08ae3b
2019-12-05 14:56:53 +01:00
WMDE-Fisch 35897a7c6e Order build dependencies alphabetically
Change-Id: I541787401d0debf4a7c1fc52636cf504493a1b1a
2019-12-05 14:08:00 +01:00
Adam Wight 430086cb6b Use the message localizer in Cite
Allows us to convert another integration test into a unit test.

Change-Id: Id7a4036e64920acdeccb4dfcf6bef31d0e5657ab
2019-12-05 13:23:31 +01:00
jenkins-bot c48c2f7942 Merge "Tests for checkRefsNoReferences" 2019-12-05 12:10:57 +00:00
jenkins-bot 6255ab85d9 Merge "Drop unused variable" 2019-12-05 10:10:20 +00:00
jenkins-bot faf0b38fd9 Merge "Add visual whitespace to concat code" 2019-12-05 10:08:47 +00:00
jenkins-bot cf45e335f8 Merge "Localisation updates from https://translatewiki.net." 2019-12-05 09:12:56 +00:00
Translation updater bot 9f305e2a6f Localisation updates from https://translatewiki.net.
Change-Id: I7effa200ea4f8e680da12b65bfccb73e504bbbb1
2019-12-05 09:45:15 +01:00
Adam Wight 4dec6afbb8 Tests for checkRefsNoReferences
One of these cannot be a unit test yet, because of a wfMessage call.

Change-Id: Ie2e2e28ee4c369cc7380c528411665fbb51691be
2019-12-05 09:14:30 +01:00
Adam Wight b575835c63 Comments to help understand the message localizer
Change-Id: Ic7c9a12a78f358d11d997abf9a3a8e996f451c8f
2019-12-05 09:06:37 +01:00
Adam Wight 855a3d6d48 Roll up a range in test fixture
This... might not be helpful.

Change-Id: Iff3342d5fbf81aa27b9aaaf1b3fc4c59fa65a365
2019-12-05 09:05:03 +01:00
Adam Wight 646dc5f974 Drop unused variable
Change-Id: I393a89ca909a632729c88ff73543bcf71061a8bf
2019-12-05 09:03:17 +01:00
Adam Wight 1f92841662 Test coverage for guardedReferences
Change-Id: Id97ba7a965dfd78579fc18e7f3d21a595e6bf432
2019-12-05 08:59:22 +01:00
jenkins-bot 336dd4a27c Merge "Complete validateRef coverage" 2019-12-04 17:18:40 +00:00
Adam Wight 3bcb8dc39f Add visual whitespace to concat code
Change-Id: I1e32c942d27db9f9c20fae0c684be256877aef2b
2019-12-04 18:12:47 +01:00
jenkins-bot 6386212f1e Merge "Tests for guardedRef" 2019-12-04 17:09:19 +00:00
Adam Wight 5705228d17 Complete validateRef coverage
Change-Id: Id61fba34a8815a0c512ecf4bc57da3be4e15c8bb
2019-12-04 18:00:13 +01:00
Adam Wight 3d049159c2 Tests for guardedRef
This is a mess of a function, and the tests show it.  There are lots
of side-effects and context-sensitivity, which can be addressed in
later work.  The interface with ReferenceStack is too wide.

Change-Id: I00cab2a555b2a9efd32d937979cd722d43ac1005
2019-12-04 16:06:10 +00:00
Thiemo Kreuz a7c4e14f42 Remove obsolete ParserBeforeTidy hook handler
I was able to track this code down to I093d85d from 2012, which was done
right after the ParserAfterParse hook was introduced. I believe the
redundant code path was left to keep the Cite extension compatible with
old MediaWiki versions that did not had this hook yet.

I also noticed this code path is most probably entirely redundant with
the current version of MediaWiki. The *only* thing this code does is
blocking the ParserBeforeTidy hook from doing the same thing a second
time if the ParserAfterParse hook was called before. But it does *not*
block any other compination, e.g. if the two hooks are called the other
way around, or the same hook twice.

In core, it looks like it is impossible for the ParserBeforeTidy hook
being fired without the ParserAfterParse hook being fired before. If this
is true, this is in fact dead code.

Change-Id: Iacf8b600c7abdeaf89c22c2fc31e646f57245e47
2019-12-04 16:56:43 +01:00
Thiemo Kreuz 31bda4777b Don't indent refs with forbidden extends="…"
Change-Id: Ied2e3f56ce66d2a8ccf60df2bdbf99acad461595
2019-12-04 15:17:03 +00:00
Adam Wight 81261493c2 Show error when extending a subreference
Change-Id: Iaa47e302e5e49dfc190fde37567a3e7a2e743d67
2019-12-04 13:49:31 +01:00
Adam Wight 484373c21e Complete tests for FootnoteBodyFormatter
Change-Id: I7cfa38f59d00be30345eb5a200f62e17197d2c76
2019-12-04 13:48:15 +01:00
Adam Wight c09d90aff3 Use message localizer in FootnoteBodyFormatter
Makes the class more easily testable.

Patch also changes an integration test into a unit test.

Change-Id: I545730404aceed7e3857d96f4fd3c1b0a900c0c2
2019-12-04 13:41:44 +01:00
Adam Wight bccb92335f Introduce ReferenceMessageLocalizer
Encapsulate the language interfaces, this will be used to replace
global wfMessage calls in future patches.

Change-Id: I7857f3e5154626e0b29977610b81103d91615f65
2019-12-04 13:40:05 +01:00
Thiemo Kreuz 0f146cd56e Fix possibly broken reference list counters in Firefox
This patch applies a few closely related changes:

1. Instead of reusing and possibly messing with the existing
"mw-ref-linkback" counter, I start a new one.

2. I also gave both new counters better names, following the
"mw-ref-…" naming scheme.

3. We must reset the build-in "list-item" counter to make this code
behave sane in Firefox. It looks like this is even described in the
CSS spec and it is not Firefox having a bug, but Chrome being "clever"
and not following the spec.

Bug: T239787
Change-Id: Ib6e9de689129b7c2d50e3a1c720c0d2d5a0c0986
2019-12-04 12:13:13 +01:00
jenkins-bot 22bc49ce8b Merge "Replace reference parameter with return value" 2019-12-04 10:48:45 +00:00
Adam Wight d04cc36fa4 Replace reference parameter with return value
This makes it obvious that our function isn't sensitive to the input value.

Also rearranges a string concatenation to make the element wrapping clearer.
I probably should have switched to the HTML class here, but I'm not sure what
the advantages would be.

Change-Id: Ife3424ce68588f73f168b10e63e6cd81c4a60084
2019-12-04 11:28:38 +01:00
Adam Wight 817c58230f Rename test to follow function name
Change-Id: I6e925f65ba7c59738ad4e55748f1efdb4cf04573
2019-12-04 11:23:55 +01:00