Divec has uploaded a new change for review.
https://gerrit.wikimedia.org/r/235686
Change subject: Allow empty external link text
......................................................................
Allow empty external link text
Allow empty <a rel='mw:ExtLink'></a> because REST API v1 can output links with
no link text (which then get a CSS generated content numbered reference).
Bug: T109576
Change-Id: I234afdb7f2c3a7a0b1b3788924393a34c408e9f2
---
M lineardoc/Builder.js
M tests/lineardoc/LinearDoc.test.js
A tests/lineardoc/data/test5-result.xhtml
A tests/lineardoc/data/test5-result.xml
A tests/lineardoc/data/test5.xhtml
5 files changed, 24 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver
refs/changes/86/235686/1
diff --git a/lineardoc/Builder.js b/lineardoc/Builder.js
index fe33c12..513bc25 100644
--- a/lineardoc/Builder.js
+++ b/lineardoc/Builder.js
@@ -83,7 +83,13 @@
}
whitespace.push( textChunk.text );
}
- if ( replace && ( tag.attributes[ 'data-mw' ] || tag.attributes[
'data-parsoid' ] ) ) {
+ if ( replace && (
+ tag.attributes[ 'data-mw' ] ||
+ tag.attributes[ 'data-parsoid' ] ||
+ // Allow empty <a rel='mw:ExtLink'></a> because REST API v1 can
output links with
+ // no link text (which then get a CSS generated content
numbered reference).
+ ( tag.name === 'a' && tag.attributes.rel === 'mw:ExtLink' )
+ ) ) {
// 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 98e4f41..80f9329 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 = 4;
+ numTests = 5;
QUnit.expect( 2 * numTests );
for ( i = 1; i <= numTests; i++ ) {
testXhtmlFile = __dirname + '/data/test' + i + '.xhtml';
diff --git a/tests/lineardoc/data/test5-result.xhtml
b/tests/lineardoc/data/test5-result.xhtml
new file mode 100644
index 0000000..faa75aa
--- /dev/null
+++ b/tests/lineardoc/data/test5-result.xhtml
@@ -0,0 +1 @@
+<ul><li about="#cite_note-2" id="cite_note-2"><span rel="mw:referencedBy"><a
href="#cite_ref-2">↑</a></span> <span class="mw-reference-text"
id="mw-reference-text-cite_note-2"><a
href="http://news.google.com/newspapers?nid=1300&dat=19610912&id=3aQUAAAAIBAJ&sjid=5qwDAAAAIBAJ&pg=4018,1662544"
id="mwEA" rel="mw:ExtLink"></a></span></li></ul>
diff --git a/tests/lineardoc/data/test5-result.xml
b/tests/lineardoc/data/test5-result.xml
new file mode 100644
index 0000000..f0d9840
--- /dev/null
+++ b/tests/lineardoc/data/test5-result.xml
@@ -0,0 +1,14 @@
+<ul>
+<li>
+<cxtextblock>
+ <cxtextchunk tags="span:rel=mw:referencedBy
a:href=#cite_ref-2">↑</cxtextchunk>
+ <cxtextchunk> </cxtextchunk>
+ <cxinlineelement
tags="span:id=mw-reference-text-cite_note-2,class=mw-reference-text">
+ <a>
+ <cxtextblock>
+ </cxtextblock>
+ </a>
+ </cxinlineelement>
+</cxtextblock>
+</li>
+</ul>
diff --git a/tests/lineardoc/data/test5.xhtml b/tests/lineardoc/data/test5.xhtml
new file mode 100644
index 0000000..e738375
--- /dev/null
+++ b/tests/lineardoc/data/test5.xhtml
@@ -0,0 +1 @@
+<ul><li about="#cite_note-2" id="cite_note-2"><span rel="mw:referencedBy"><a
href="#cite_ref-2">↑</a></span> <span id="mw-reference-text-cite_note-2"
class="mw-reference-text"><a rel="mw:ExtLink"
href="http://news.google.com/newspapers?nid=1300&dat=19610912&id=3aQUAAAAIBAJ&sjid=5qwDAAAAIBAJ&pg=4018,1662544"
id="mwEA"></a></span></li></ul>
--
To view, visit https://gerrit.wikimedia.org/r/235686
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I234afdb7f2c3a7a0b1b3788924393a34c408e9f2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Divec <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits