BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/332423 )

Change subject: Remove title from reference links
......................................................................

Remove title from reference links

Bug: T155070
Change-Id: I7acf9d46b3867cbd1017deef39c3616990f31196
---
M lib/transforms.js
1 file changed, 20 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/23/332423/1

diff --git a/lib/transforms.js b/lib/transforms.js
index 481bd90..a647594 100644
--- a/lib/transforms.js
+++ b/lib/transforms.js
@@ -83,6 +83,23 @@
     }
 }
 
+/**
+ * Remove title from reference links so the current implementation of the 
Android
+ * still works. See T155070. This is probably just a temporary fix until the 
app
+ * releases a version which can handle the addition of the title, too.
+ */
+function _removeTitleFromReferenceLinks(doc, selector, attribute, title) {
+    const ps = doc.querySelectorAll(selector) || [];
+    for (let idx = 0; idx < ps.length; idx++) {
+        const node = ps[idx];
+        let value = node.getAttribute(attribute);
+        if (value) {
+            value = value.replace(`${title}#`, '#');
+            node.setAttribute(attribute, value);
+        }
+    }
+}
+
 function _rewriteUrlAttribute(doc, selector, attribute) {
     const ps = doc.querySelectorAll(selector) || [];
     for (let idx = 0; idx < ps.length; idx++) {
@@ -223,6 +240,9 @@
  * Nukes stuff from the DOM we don't want for pages from Parsoid.
  */
 transforms.stripUnneededMarkup = function(doc, legacy) {
+    const title = doc.querySelector('html > head > title').innerHTML || '';
+    _removeTitleFromReferenceLinks(doc, `span[typeof~=mw:Extension/ref] 
a[href^=${title}#]`, 'href', title);
+
     _runAllSectionsTransforms(doc);
     // runLeadSectionTransforms(doc);
     _applyOptionalParsoidSpecificTransformations(doc);

-- 
To view, visit https://gerrit.wikimedia.org/r/332423
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7acf9d46b3867cbd1017deef39c3616990f31196
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND <bsitzm...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to