Commit graph

103 commits

Author SHA1 Message Date
C. Scott Ananian 6b813c6874 Sync up with Parsoid citeParserTests.txt
This now aligns with Parsoid commit d9a3e14dfcb422e95de7a79f0eb662fd43f9354f

Change-Id: Iae34d2107bfb47304819da7f7c715dec83da1a48
2020-08-18 16:54:33 -04:00
C. Scott Ananian a0faedb942 Sync up with Parsoid citeParserTests.txt
This now aligns with Parsoid commit 77db605163990ad851e3da0fb4fa7eca2081f379

Change-Id: I19ad9f1b6845e5557c2f5f87ac435db0ad87000d
2020-07-28 15:53:08 -04:00
C. Scott Ananian 90728bde87 Sync up with Parsoid citeParserTests.txt
This now aligns with Parsoid commit 7321ab547b7663ba86c1cfe0bc021ff1918c0970

Change-Id: I2cc88069b19e7611f23c83ca993f9caa70f786f0
2020-07-15 11:39:46 -04:00
Bartosz Dziewoński 1975cb3dcb Do not add thousands separators when formatting reference numbers
Bug: T253743
Change-Id: I8c4de963277895d7751d6bfe3c34ca6097ebe606
2020-05-28 00:08:44 +02:00
Thiemo Kreuz 7fbd5de7f5 Merge two code paths related to follow
This patch also adds a test case that was missing before. If a
follow="…" is followed by another, normal <ref>, the internal key
(a.k.a. $this->refSequence) is not incremented. This was the case
before, just not covered by any test.

Change-Id: I102d1e67a6918017acc7e4a4663b08c828d101a6
2020-05-12 10:52:08 +02:00
jenkins-bot 53cf713cdb Merge "Add test cases for impossible follow vs. rollback edge case" 2020-05-12 02:03:35 +00:00
Subramanya Sastry eb8e07c69c Sync up with Parsoid citeParserTests.txt
This now aligns with Parsoid commit 1e72ddefc2df8d5b38d7b370d67a87b48d8a09f7

Change-Id: Ic75ac33c92997427751d037339f7eb79027356a2
2020-05-07 12:14:19 -05:00
Bartosz Dziewoński 3678215a77 Add a newline in wikitext before autogenerated reflist
Previously the reflist was added at the end of the last line of text,
which messes up paragraph wrapping (as seen in many test cases), and
generated invalid HTML when the last line was a list item (T148701).

(second try, previously reverted in 8c933d03c5)

Note this affects only pages where the <references /> tag is missing,
and the references section is auto-generated at the very end of the page.

Bug: T148701
Change-Id: Ib2101346434a4e317b5fc7379215b60c7020cb2b
2020-05-06 20:51:25 +02:00
C. Scott Ananian 376c0418d3 Update parser tests to v2 (tidy by default)
The most common cleanup required by switching to tidy output was adding
missing <p>-wrappers to the last item before <references/>.

Bug: T246285
Change-Id: I7c8a08c4e6eff7caf4539a26fae475a4133f9a0c
2020-04-01 11:11:13 -04:00
Thiemo Kreuz a00b8d990d Add test cases for impossible follow vs. rollback edge case
While working on the patch I4303642 I was worried about the line

array_pop( $this->refCallStack )

in the rollback code. Since the patch changed the position of follow
elements in the stack, an array_pop() would pop different elements.

It turns out this is impossible. Rollbacks are only done for <ref>
elements inside a <references> tag, immediatelly after reaching the
closing </references>. It's impossible to use follow="…" inside
<references>. It will not be added to the stack, and therefore not
rolled back.

Even if the edge case would be possible, the *old* code that placed
follow elements on the *other* side of the stack would have been
wrong then.

The test cases in this patch try to hit this edge case, and are
expected to not be able to do so.

Change-Id: I4380bf443db17c6214dbfa2cbda62b46db04258a
2020-04-01 09:03:19 +00:00
Awight 8c933d03c5 Revert "Add a newline in wikitext before autogenerated reflist"
This reverts commit 90697ffe43.

Change-Id: I659ce1689603fd16e378fb8d3d5bd6d1089342b2
2020-04-01 08:03:55 +00:00
Bartosz Dziewoński 90697ffe43 Add a newline in wikitext before autogenerated reflist
Previously the reflist was added at the end of the last line of text,
which messes up paragraph wrapping (as seen in many test cases), and
generated invalid HTML when the last line was a list item (T148701).

Bug: T148701
Change-Id: Ifc873fc913e717026d80d54b570c594d1073fb42
2020-03-31 19:00:51 +00:00
Thiemo Kreuz 48e2f02e20 Add two extreme follow edge cases back to parser tests
This reverts parts of the revert I3bee35f, which reverted a3d312c8.
I believe it's helpful to keep these test cases just to document how
the code currently behaves. I removed all TODO because we don't know
if and how we want to touch this again.

Bug: T240858
Change-Id: Ib91acfcb7292e5c03ce9cc4d7be782085e10aa27
2020-02-05 15:04:49 +01:00
Adam Wight f2bd6b6dcc Revert "Standardize "follow" validation"
This reverts commit a3d312c8f4.

Bug: T240858
Change-Id: I3bee35f27797a04c41c265f7e598d8383414b67a
2020-02-05 11:42:28 +01:00
Adam Wight a3d312c8f4 Standardize "follow" validation
Perform the validation in validateRef, and display a new error message for
broken "follow" refs.  This changes existing behavior, where broken folow
ref content is arbitrarily displayed at the top of the references list and
no error is rendered.

Thanks to weasely wording, the new error can later be reused for "extends"
errors.

Bug: T240858
Change-Id: I506e4dcd1151671f5302ecd99581145d979d8124
2020-01-30 17:25:42 +00:00
jenkins-bot 3c8a225052 Merge "Fix incomplete rollback producing bad footnote numbers" 2020-01-24 15:11:31 +00:00
Thiemo Kreuz 2ddc6f133b Fix incomplete rollback producing bad footnote numbers
Bug: T48140
Change-Id: I53ce5d8488d4c24d6f23f6f0e70806d7db4064e1
2020-01-24 13:02:53 +01:00
Thiemo Kreuz 816b1b0add Remove newline characters from all error messages
These create bogus output, depending on the surrounding wikitext the
<ref> tag is used in. For example, this example wikitext:

* Example.<ref name="1">a</ref> More text.

… will be rendered with the "More text" sentence wrapped on the next
line, outside of the list. However, this does *not* happen in many of
the localizations, e.g. German, because many Tanslatewiki translators
did not copied the bogus \n. Why should they.

TL;DR: These newline characters either do nothing, or destroy the output.
In both cases the proper fix is to replace them with spaces.

Some of the test cases touched in this patch demonstrate the issue.

Change-Id: I395a40637a5293eda1f477963d252ce1a215f8b2
2020-01-24 12:29:14 +01:00
Thiemo Kreuz 51d55bb8de Introduce dedicated error message for nested <ref extends=…>
This resolves another TODO. Since this is an intentional limitation in
the design of the feature, I find it pretty signigicant to give it it's
own error message.

Note that the text does not need to be perfect, just good enough for now.
We will review all error messages later via T238188.

Bug: T242141
Change-Id: Id9c863061e855350320131e81f6702c8810736f4
2020-01-23 15:00:26 +01:00
Thiemo Kreuz 9565d6e887 Resolve a TODO by covering it with a test case
It turns out this is indeed necessary. The test demonstrates why.

Change-Id: Id9c6a48f72ef8d3f0cc9a714d826418e69913b0a
2020-01-21 10:11:03 +00:00
jenkins-bot 258b23a6dd Merge "Error when reusing <ref> with conflicting "extends" attributes" 2020-01-20 13:49:41 +00:00
Adam Wight 8a58ed55dc Error when reusing <ref> with conflicting "extends" attributes
"Conflicting" here includes the case where one of two <ref> with the
same name does not have an extends attribute. The first occurence of
a name specifies if a <ref> is a top-level or a sub-reference. This can
not be changed later.

This patch changes multiple existing test cases. I checked all of them
in detail and confirmed the behavior is fine. The error reporting is
better or at least equally good in all cases.

Bug: T242141
Change-Id: Iaec306eefe5b168d496990105e297ca044a5e721
2020-01-20 13:33:52 +00:00
Adam Wight b3ea9f4ef8 Relax empty-string name validation
Allow a ref with `name=""` for backwards-compatibility.
Partially reverts I07738cce2641026dfaa92ba263ed6f9834be0944

Bug: T242437
Change-Id: Iaed2d1c41be377a4961aff39838b0965f6c00616
2020-01-20 12:40:09 +00:00
Arlo Breault 7e2bbae4c2 Sync up with Parsoid citeParserTests.txt
This now aligns with Parsoid commit 0a6c576ad6ccfc81c2bfa20757417c62e554ef56

Change-Id: Ifa5d60e362e5c530d12d3b94351aef2d1b1962cc
2020-01-17 14:51:03 -05:00
Adam Wight f3031b80b9 Fix for blank-named ref in #tag
A fun edge case where `name=""` fools both validation branches after
a references rollback, and triggered a LogicException.  Stop these
freak refs.

Bug: T242437
Change-Id: I07738cce2641026dfaa92ba263ed6f9834be0944
2020-01-17 11:19:29 +01:00
Adam Wight 1c947a808d Fix for nested #tag:references
It's possible to nest <references> by using tricky constructs like the
{{#tag function, and this breaks our rollback logic.  Try to show normal
output, otherwise show an error.

Includes regression tests.

Bug: T242437
Change-Id: I33e497cdf8508ce7ccb7f0f315c00af5eee47d0e
2020-01-15 12:44:29 +01:00
jenkins-bot 09f4deede4 Merge "Replace now unused native cloning feature" 2020-01-09 14:13:58 +00:00
Adam Wight 170484e933 Annotate TODOs with task number
Each of these TODOs is something that needs to be fixed or implemented,
so it's helpful to map them to tasks.

Change-Id: I807208392d8a609d7f3b371dc3560a48f3578092
2020-01-09 13:13:48 +01:00
jenkins-bot 0be582dc12 Merge "Report conflicting extends="…" with an error message" 2020-01-09 11:37:27 +00:00
jenkins-bot b9b6905171 Merge "Fix incomplete undo/redo stack implementation" 2020-01-09 10:58:35 +00:00
Thiemo Kreuz 04fbbbd3ca Report conflicting extends="…" with an error message
Bug: T242110
Change-Id: I04342b2c219981dfb9575ea58cfccf6c2ba1066c
2020-01-08 16:47:07 +00:00
Thiemo Kreuz d07110b790 Fix incomplete undo/redo stack implementation
The rollback feature was not able to properly restore a __placeholder__.
That's why a specific use case was behaving different. This already
worked just fine:

<ref extends="a">…</ref>
<references>
<ref name="a">…</ref>
</references>

But this didn't, even if it is the exact same from the users
perspective:

<ref extends="a">…</ref>
{{#tag:references|
<ref name="a">…</ref>
}}

Bug: T239810
Change-Id: I163a1bffb9450a9e7f776e32e66fb08d0452cdb9
2020-01-08 17:43:02 +01:00
Adam Wight b7c9dbb0d5 Remove invalid test case
Unnamed references are never merged.

Bug: T239788
Bug: T240459
Change-Id: I8dd3706c688108bf2e3c0e9b55f123084b325d16
2020-01-08 16:59:28 +01:00
jenkins-bot 861c4edba7 Merge "Test cases for extends pointing to the <references> section" 2020-01-08 10:42:14 +00:00
Thiemo Kreuz 6ddfd9983b Fix bad numbering when reusing sub-references
Note this leaves *another* bug behind. When a <ref> is properly reused
by name="…", and the content is fine (either missing or identical),
possibly conflicting extends="…" attributes are currently entirely
ignored. However, this is already much better than what happened before.

Bug: T242110
Change-Id: Id808ce31c8036cc290f68bb3e8c5a7b12f4f44cf
2020-01-07 16:34:05 +01:00
Thiemo Kreuz 5db90fb5a9 Test cases for extends pointing to the <references> section
This is an extremely relevant use case, but we never had a test for
this:

Some text.<ref extends="book">Page 2</ref>

<references>
  <ref name="book">Title of the book</ref>
</references>

What this means: There is no reference in the text that points to the
book as a whole, only references that point to individual pages. The
base <ref> is not used in the text.

This is already properly rendered. There is no "jump back to the text"
link. However, this fails when <references> is wrapped in {{#tag:…}}.

Bug: T239810
Change-Id: Id22db0238266a4fd6131d1a10eb6bf6227552c19
2020-01-07 12:43:18 +01:00
Thiemo Kreuz 38d5bd5f39 Add missing parser tests for relevant responsive edge cases
I tried to run these tests with a very old version of this code base
(from 2018) to confirm this is the correct behavior.

Bug: T241303
Change-Id: Id97d016b199458aa178ca732282e9c0e91e291a4
2019-12-28 20:59:23 +00:00
Thiemo Kreuz 0dc6f37785 Replace now unused native cloning feature
Since I3db5175 the ParserCloned hook handler does not rely on cloning
the Cite object any more. There is no cloning any more. This is dead
code and we could remove it. Just to be sure I propose to keep the
method, but let it throw an exception.

Bug: T240248
Change-Id: I2057ea652ca25f4c7031c28a6e713671738f5e22
2019-12-20 20:07:59 +01:00
jenkins-bot 45119f8c61 Merge "Move "dir" error handling to validation" 2019-12-19 10:18:24 +00:00
Arlo Breault 6d55f9e8cc Sync up with Parsoid citeParserTests.txt
This now aligns with Parsoid commit 41f397ce4d563fa7f7770725d88944dcabda4116

Change-Id: I27b7f035c8b99ca80501b8cd1169ed8c8895ef93
2019-12-18 15:30:49 -05:00
jenkins-bot 0d7e04e1ee Merge "Fix inconsistent error reporting for invisible content" 2019-12-18 09:27:03 +00:00
Adam Wight 1e82f8f073 Move "dir" error handling to validation
Note that this patch changes behavior, an invalid "dir" will result in
a cite reference at the point where the <ref> is declared rather than
in the references section.  This is consistent with other errors.

Bug: T15673
Change-Id: Id10db40aa0b391f2f1d9274aa09d22a7278d65e3
2019-12-18 10:05:59 +01:00
Thiemo Kreuz 1f76199ed8 Add parser tests for the responsive="…" feature
Change-Id: Id9d733dabf82f2c26f51c6fbd1e03fe0574e88a8
2019-12-17 15:51:41 +01:00
Thiemo Kreuz 1bd66081f7 Fix inconsistent error reporting for invisible content
This makes one of the last remaining edge-cases about non-empty, but
non-visible content (a <ref> that only contains whitespace) behave
identical to all other places. We already reported it as being empty
everywhere else, except inside of <references>.

Note that the test cases look like they are reporting the same errors
twice. But this is not the case:

The first set of errors is about <ref name="…"> inside of <references>
not having visible content. This should always be reported, even if the
<ref> got content from somewhere else on the page.

The second set of errors is when a <ref name="…"> *never* got any
content.

This patch will slightly increase the numbers of errors reported.

Change-Id: I4a156aa9e466f735d92fe0ba5cc0678ec8bbdd50
2019-12-17 13:37:01 +01:00
Thiemo Kreuz f86b5073fd Add parser tests for reused extended <ref> before defined
Bug: T240424
Change-Id: I945c2e12cfa3ff851380a1ff4491c8af076f523a
2019-12-11 16:30:17 +01:00
Thiemo Kreuz 193b840010 Add parser test for duplicate extended references
Bug: T240459
Change-Id: Ifc7a695e89a49ccc6c66d49efe41b2321b0915f0
2019-12-11 15:58:34 +01:00
Adam Wight 084ca6b3d4 Integration parser test for ParserFunctions
Depends-On: I09844079f163e583d3b1e941c701f8cda5029a0a
Bug: T240345
Change-Id: I86c55ff88d9f4b800e8868728dfec6b4ceda82c2
2019-12-11 08:58:58 +01:00
Thiemo Kreuz f92792f64a Fix bad localization of extended references numbers when reused
This adds a test for numbers like "1.2.0" that appear when an extended
reference (e.g. "1.2.") is reused multiple times.

The first separator is from the extended reference. We decided to never
localize it. However, the second seperator is from reusing a reference.
This was always localized. We believe this is a bug, but haven't fixed
it yet.

The test is documenting the status quo "1.2,0" with a comma. This kind
of makes sense, one could argue, because the "1.2" appears like this up
in the text, but the ",0" is a different indicator for a reuse, which
*never* occurs in the text.

Change-Id: Ie3d26bcadd8929b906bfbcac4806af2150d61f2a
2019-12-09 17:25:14 +01:00
Adam Wight f51060eaf4 Fix footnote mark after extends numbering glitch
The visible numbering needed to be rolled back after an extends.

Bug: T237241
Change-Id: I95404515110df1fa7e3279ea499577df0ed45ddf
2019-12-09 12:06:59 +01:00
jenkins-bot 3b41cfa472 Merge "Fail early on nested extends="…", if possible" 2019-12-09 10:12:54 +00:00