Commit graph

3220 commits

Author SHA1 Message Date
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
Adam Wight 97e0cd2321 Minor cleanups
Change-Id: I895d16a17e7d7e30a2118e798fb453192ea282b3
2019-12-04 09:26:52 +00:00
jenkins-bot 51bf977667 Merge "Stop formatting "1.2" as "1,2" in languages like German" 2019-12-04 09:10:21 +00:00
Thiemo Kreuz 54333c9bd6 Stop formatting "1.2" as "1,2" in languages like German
The new extends="…" feature is using numbers like "1.2". These should be
localized in languages like Hebrew that uses other symbols for the digits.
But the "." should not change.

The existing feature when a <ref> is reused multiple times does have the
same "issue". But it seems this is intentional, because it is covered by
a test. Note this is not visible in German, because German uses custom
labels "a", "b", and so on.

This patch also improves the so called "smoke" tests and makes one cover
numbers up to "1,10" for a <ref> that is reused that often.

Bug: T239725
Change-Id: Iffcb56e1c7be09cefed9dabb1d6391eb6ad995ce
2019-12-04 09:43:04 +01:00
Translation updater bot 350bba502a Localisation updates from https://translatewiki.net.
Change-Id: I1fc295815f12480d430893e78e4d6d28d8261afd
2019-12-04 09:22:40 +01:00
Adam Wight d40bf92396 Make integration test into a unit test
We were mocking ParserOutput anyway, so this is the same test as before.

Change-Id: If31898b537db946b6b4a595663d3894d05d94e77
2019-12-03 14:07:48 +01:00
Adam Wight 1b82b93835 Fix function signature in phpdoc
Change-Id: I3329ca19d465c6ad7ed23385021a051fcc23ea8e
2019-12-03 13:26:50 +01:00
jenkins-bot 191cb2bea1 Merge "Fix top-level reference numbering" 2019-12-03 11:56:08 +00:00
Adam Wight 0f2c56e0ac Fix top-level reference numbering
This fixes a Firefox-only glitch where the CSS counter was messing
with the native list numbering. Example:
https://en.wikipedia.beta.wmflabs.org/wiki/Draft:Cut_the_Crap

Change-Id: I6e6514e73bcf6485402b6a61aa5202ebb83a6479
2019-12-03 12:32:29 +01:00
jenkins-bot 0f9c306748 Merge "Inline and streamline code in the formatter classes" 2019-12-03 10:42:28 +00:00
Thiemo Kreuz b145869980 Inline and streamline code in the formatter classes
* Don't use string comparisons to compare numbers.
* Avoid isset() for variables that are guaranteed to exist.
* Inline two small "gen…" functions that are only called once.
* Move the fallback code path out of getLinkLabel(). Before it was
  always called. Now it's only called when needed.

Change-Id: I42073f57f21d32c7936954da776ef3a393410020
2019-12-03 10:26:38 +01:00
Adam Wight 96db7944eb Cover rollback with tests
Fixed an unsafe array access during rollback.

Change-Id: Id9ee8976e3bae24501c18abf462e3e19894caff0
2019-12-03 09:53:23 +01:00
Adam Wight 4cf8faea48 Cover edge cases with unit tests
Change-Id: If715788292631f2e1f4cf970c1ae7c7fd7d514e1
2019-12-03 09:53:23 +01:00
Adam Wight 008526b3aa Can use extends before its parent
If `extends` is encountered before the parent ref, we reserve the
sequence number and leave a placeholder to record the link between
ref name and number.  This is necessary to render a list like,
"[1] [2.1] [2]", or to use subreferencing when the parent ref is
declared in the references tag.

When a placeholder is encountered during references section rendering,
it means that the parent was never declared.

Change-Id: I611cd1d73f775908926a803fae90d039ce122ab6
2019-12-02 17:14:11 +01:00
Adam Wight a27c33a2e7 Cleanups
Address some code review comments from I75bd6644

Change-Id: I433c08318c137ecca4d4ef77f0863d5da42b567c
2019-12-02 16:36:49 +01:00
jenkins-bot 221e657dfe Merge "Formatter takes responsibility for rendering footnote mark" 2019-12-02 15:32:05 +00:00
jenkins-bot fa4410836d Merge "Split ref.number field" 2019-12-02 15:29:53 +00:00
jenkins-bot 79e7b2b474 Merge "Add test cases for duplicate <references> with same group" 2019-12-02 15:26:02 +00:00
Thiemo Kreuz 2cb7e5d438 Add test cases for duplicate <references> with same group
Change-Id: I9603e7ebf167330b1eddae1676e9234edf6557bc
2019-12-02 15:08:15 +00:00
Adam Wight e9958d569b Formatter takes responsibility for rendering footnote mark
Pass the full ref structure from ReferenceStack to FootnoteMarkFormatter,
to give it control over the final rendering.  This is aligned with how
the FootnoteBodyFormatter directly scans over groupRefs.

Change-Id: I3294fd9366f01daa4250a5d481f4adbae84c72b1
2019-12-02 10:17:24 +01:00