jenkins-bot has submitted this change and it was merged.
Change subject: Lineardoc: Fix the reference parsing
......................................................................
Lineardoc: Fix the reference parsing
Parsoid started to output references in the following format:
<span about="#mwt8" class="mw-ref" id="cite_ref-4" rel="dc:references"
typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":
"mw-reference-text-cite_note-4"},"attrs":{}}'>
<a href="#cite_note-4" style="counter-reset: mw-Ref 4;">
<span class="mw-reflink-text">[4]</span>
</a>
</span>
And, our lineardoc started to wrongly output the content as
<span about="#mwt8" class="mw-ref" id="cite_ref-4" rel="dc:references"
typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":
"mw-reference-text-cite_note-4"},"attrs":{}}'>
<a href="#cite_note-4" style="counter-reset: mw-Ref 4;">
<span class="mw-reflink-text">[4]</span>
</a>
</span>
<a href="#cite_note-4" style="counter-reset: mw-Ref 4;"></a>
The extra <a> tag is problematic and causes references appearing twice
in CX translation interface.
The extra <a> was a regression introduced in
I4cca925cb35a00fa27fd31380fae90e1c4c2767f,
and its test had to be corrected, too.
While processing inline annotation tags like above, we were
skipping the internal inline empty spans and that was fixed in
I4cca925cb35a00fa27fd31380fae90e1c4c2767f
But, when we started processing the internal annotations, we were
inserting a new inline content when there is non-whitespace content.
But that caused inserting inline content in unwanted situations, too.
The above example shows an <a> tag inserted in that way.
Making the conditions for this insertion a bit stricter proved to work.
We are checking if those inline annotations are having any of data-mw,
data-parsoid attributes. I am not 100% sure, however, that it is
the correct solution to meet any future changes like this.
Added tests with new reference structure. The parsoid DOM spec
https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Ref_and_References
does not seem to reflect this change.
Bug: T107140
Change-Id: I68bd92ecf4190f62db9b715f66f63cfada3aea57
---
M lineardoc/Builder.js
M tests/lineardoc/LinearDoc.test.js
M tests/lineardoc/data/test3-result.xhtml
M tests/lineardoc/data/test3-result.xml
A tests/lineardoc/data/test4-result.xhtml
A tests/lineardoc/data/test4-result.xml
A tests/lineardoc/data/test4.xhtml
7 files changed, 21 insertions(+), 9 deletions(-)
Approvals:
Santhosh: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lineardoc/Builder.js b/lineardoc/Builder.js
index 8874681..fe33c12 100644
--- a/lineardoc/Builder.js
+++ b/lineardoc/Builder.js
@@ -83,7 +83,7 @@
}
whitespace.push( textChunk.text );
}
- if ( replace ) {
+ if ( replace && ( tag.attributes[ 'data-mw' ] || tag.attributes[
'data-parsoid' ] ) ) {
// truncate list and add data span as new sub-Doc.
this.textChunks.length = i + 1;
whitespace.reverse();
diff --git a/tests/lineardoc/LinearDoc.test.js
b/tests/lineardoc/LinearDoc.test.js
index 13a1007..98e4f41 100644
--- a/tests/lineardoc/LinearDoc.test.js
+++ b/tests/lineardoc/LinearDoc.test.js
@@ -6,7 +6,7 @@
QUnit.test( 'LinearDoc tests', function ( assert ) {
var parser, testXhtmlFile, resultXmlFile, resultXhtmlFile, testXhtml,
resultXml,
resultXhtml, i,
- numTests = 3;
+ numTests = 4;
QUnit.expect( 2 * numTests );
for ( i = 1; i <= numTests; i++ ) {
testXhtmlFile = __dirname + '/data/test' + i + '.xhtml';
diff --git a/tests/lineardoc/data/test3-result.xhtml
b/tests/lineardoc/data/test3-result.xhtml
index d6ac7fa..ae458bc 100644
--- a/tests/lineardoc/data/test3-result.xhtml
+++ b/tests/lineardoc/data/test3-result.xhtml
@@ -6,7 +6,7 @@
<body>
<ol>
<li about="#cite_note-5" id="cite_note-5">
-<a href="#cite_ref-5" rel="mw:referencedBy"><span class="mw-linkback-text">↑
</span></a><a href="#cite_ref-5" rel="mw:referencedBy"></a>
+<a href="#cite_ref-5" rel="mw:referencedBy"><span class="mw-linkback-text">↑
</span></a>
<span class="mw-reference-text" data-parsoid="{}"
id="mw-reference-text-cite_note-5"><a
data-parsoid="{"targetOff":4337,"contentOffsets":[4337,4337],"dsr":[4248,4338,89,1]}"
href="http://lhermanto-resepkeluarga.blogspot.com/2008/04/telor-bumbu-bali-bali-seasoning.html"
rel="mw:ExtLink"></a></span>
</li>
</ol>
diff --git a/tests/lineardoc/data/test3-result.xml
b/tests/lineardoc/data/test3-result.xml
index f0bc5b3..92c83e4 100644
--- a/tests/lineardoc/data/test3-result.xml
+++ b/tests/lineardoc/data/test3-result.xml
@@ -27,12 +27,6 @@
<cxtextblock>
<cxtextchunk> </cxtextchunk>
<cxtextchunk tags="a:href=#cite_ref-5,rel=mw:referencedBy
span:class=mw-linkback-text">↑ </cxtextchunk>
- <cxinlineelement>
- <a>
- <cxtextblock>
- </cxtextblock>
- </a>
- </cxinlineelement>
<cxtextchunk> </cxtextchunk>
<cxinlineelement
tags="span:id=mw-reference-text-cite_note-5,class=mw-reference-text,data-parsoid={}">
<a>
diff --git a/tests/lineardoc/data/test4-result.xhtml
b/tests/lineardoc/data/test4-result.xhtml
new file mode 100644
index 0000000..c2ecf48
--- /dev/null
+++ b/tests/lineardoc/data/test4-result.xhtml
@@ -0,0 +1,2 @@
+<p id="mwFQ"><span about="#mwt8" class="mw-ref"
data-mw="{"name":"ref","body":{"id":"mw-reference-text-cite_note-4"},"attrs":{}}
+" id="cite_ref-4" rel="dc:references" typeof="mw:Extension/ref"><a
href="#cite_note-4" style="counter-reset: mw-Ref 4;"><span
class="mw-reflink-text">[4]</span></a></span></p>
diff --git a/tests/lineardoc/data/test4-result.xml
b/tests/lineardoc/data/test4-result.xml
new file mode 100644
index 0000000..1f825b3
--- /dev/null
+++ b/tests/lineardoc/data/test4-result.xml
@@ -0,0 +1,11 @@
+<p>
+<cxtextblock>
+ <cxinlineelement>
+ <cxwrapper>
+ <cxtextblock>
+ <cxtextchunk tags="a:href=#cite_note-4,style=counter-reset: mw-Ref 4;
span:class=mw-reflink-text">[4]</cxtextchunk>
+ </cxtextblock>
+ </cxwrapper>
+ </cxinlineelement>
+</cxtextblock>
+</p>
diff --git a/tests/lineardoc/data/test4.xhtml b/tests/lineardoc/data/test4.xhtml
new file mode 100644
index 0000000..951e145
--- /dev/null
+++ b/tests/lineardoc/data/test4.xhtml
@@ -0,0 +1,5 @@
+<p id="mwFQ"><span about="#mwt8" class="mw-ref" id="cite_ref-4"
+rel="dc:references" typeof="mw:Extension/ref"
+data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-4"},"attrs":{}}
+'><a href="#cite_note-4" style="counter-reset: mw-Ref 4;"><span
+class="mw-reflink-text">[4]</span></a></span></p>
--
To view, visit https://gerrit.wikimedia.org/r/227435
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I68bd92ecf4190f62db9b715f66f63cfada3aea57
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
Gerrit-Reviewer: Divec <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits