jenkins-bot has submitted this change and it was merged.

Change subject: No longer strip parenthetical content from first sentence.
......................................................................


No longer strip parenthetical content from first sentence.

This was an experiment to try to improve the readability of the first
sentence of the article, which often contains information in parentheses.
But, since the (relatively naive) algorithm for removing parentheses also
affects links that have parentheses in them, this was doing more harm than
good by breaking these links.

Note: we are still stripping parenthetical content from link previews, but
that's because we don't enable links within the preview. If we end up
enabling links in the preview, then we'll need to revisit this issue.

Bug: T96871
Change-Id: Ic01e82cdf088f6acb42b80f2c355d300907e3950
---
M app/src/main/assets/bundle.js
M www/js/transforms/relocateFirstParagraph.js
2 files changed, 0 insertions(+), 96 deletions(-)

Approvals:
  Mholloway: Looks good to me, approved
  Niedzielski: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/app/src/main/assets/bundle.js b/app/src/main/assets/bundle.js
index d91e474..af6c29b 100644
--- a/app/src/main/assets/bundle.js
+++ b/app/src/main/assets/bundle.js
@@ -1024,48 +1024,6 @@
 
},{"../transformer":12,"./collapseTables":16}],20:[function(require,module,exports){
 var transformer = require("../transformer");
 
-// Takes a block of text, and removes any text within parentheses, but only
-// until the end of the first sentence.
-// Based on Extensions:Popups - ext.popups.renderer.article.js
-function removeParensFromText( string ) {
-    var ch;
-    var newString = '';
-    var level = 0;
-    var i = 0;
-    for( ; i < string.length; i++ ) {
-        ch = string.charAt( i );
-        if ( ch === ')' && level === 0  ) {
-            // abort if we have an imbalance of parentheses
-            return string;
-        }
-        if ( ch === '(' ) {
-            level++;
-            continue;
-        } else if ( ch === ')' ) {
-            level--;
-            continue;
-        }
-        if ( level === 0 ) {
-            // Remove leading spaces before parentheses
-            if ( ch === ' ' && (i < string.length - 1) && string.charAt( i + 1 
) === '(' ) {
-                continue;
-            }
-            newString += ch;
-            if ( ch === '.' ) {
-                // stop at the end of the first sentence
-                break;
-            }
-        }
-    }
-    // fill in the rest of the string
-    if ( i + 1 < string.length ) {
-        newString += string.substring( i + 1, string.length );
-    }
-    // if we had an imbalance of parentheses, then return the original string,
-    // instead of the transformed one.
-    return ( level === 0 ) ? newString : string;
-}
-
 // Move the first non-empty paragraph of text to the top of the section.
 // This will have the effect of shifting the infobox and/or any images at the 
top of the page
 // below the first paragraph, allowing the user to start reading the page 
right away.
@@ -1106,12 +1064,6 @@
 
         // Move the P!
         block_0.insertBefore(p.parentNode.removeChild(p), block_0.firstChild);
-
-        // Transform the first sentence of the first paragraph.
-        // (but only for non-production, and only on enwiki)
-        if ( window.isBeta && window.siteLanguage.indexOf( "en" ) > -1 ) {
-            p.innerHTML = removeParensFromText(p.innerHTML);
-        }
 
         // But only move one P!
         break;
diff --git a/www/js/transforms/relocateFirstParagraph.js 
b/www/js/transforms/relocateFirstParagraph.js
index 095ffd8..8b0f9e5 100644
--- a/www/js/transforms/relocateFirstParagraph.js
+++ b/www/js/transforms/relocateFirstParagraph.js
@@ -1,47 +1,5 @@
 var transformer = require("../transformer");
 
-// Takes a block of text, and removes any text within parentheses, but only
-// until the end of the first sentence.
-// Based on Extensions:Popups - ext.popups.renderer.article.js
-function removeParensFromText( string ) {
-    var ch;
-    var newString = '';
-    var level = 0;
-    var i = 0;
-    for( ; i < string.length; i++ ) {
-        ch = string.charAt( i );
-        if ( ch === ')' && level === 0  ) {
-            // abort if we have an imbalance of parentheses
-            return string;
-        }
-        if ( ch === '(' ) {
-            level++;
-            continue;
-        } else if ( ch === ')' ) {
-            level--;
-            continue;
-        }
-        if ( level === 0 ) {
-            // Remove leading spaces before parentheses
-            if ( ch === ' ' && (i < string.length - 1) && string.charAt( i + 1 
) === '(' ) {
-                continue;
-            }
-            newString += ch;
-            if ( ch === '.' ) {
-                // stop at the end of the first sentence
-                break;
-            }
-        }
-    }
-    // fill in the rest of the string
-    if ( i + 1 < string.length ) {
-        newString += string.substring( i + 1, string.length );
-    }
-    // if we had an imbalance of parentheses, then return the original string,
-    // instead of the transformed one.
-    return ( level === 0 ) ? newString : string;
-}
-
 // Move the first non-empty paragraph of text to the top of the section.
 // This will have the effect of shifting the infobox and/or any images at the 
top of the page
 // below the first paragraph, allowing the user to start reading the page 
right away.
@@ -82,12 +40,6 @@
 
         // Move the P!
         block_0.insertBefore(p.parentNode.removeChild(p), block_0.firstChild);
-
-        // Transform the first sentence of the first paragraph.
-        // (but only for non-production, and only on enwiki)
-        if ( window.isBeta && window.siteLanguage.indexOf( "en" ) > -1 ) {
-            p.innerHTML = removeParensFromText(p.innerHTML);
-        }
 
         // But only move one P!
         break;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic01e82cdf088f6acb42b80f2c355d300907e3950
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <dbr...@wikimedia.org>
Gerrit-Reviewer: BearND <bsitzm...@wikimedia.org>
Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org>
Gerrit-Reviewer: Mholloway <mhollo...@wikimedia.org>
Gerrit-Reviewer: Niedzielski <sniedziel...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to