Mholloway has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/242149

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

No longer strip parenthetical content from first sentence.

[Note: copied from dbrant's app-side patch at
https://gerrit.wikimedia.org/r/#/c/242135/]

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: Iafa8d3213c9b824d8c6ebffd22a1b4b34fe38709
---
M www/js/transforms/relocateFirstParagraph.js
1 file changed, 1 insertion(+), 49 deletions(-)


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

diff --git a/www/js/transforms/relocateFirstParagraph.js 
b/www/js/transforms/relocateFirstParagraph.js
index 095ffd8..77cb1c2 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.
@@ -83,13 +41,7 @@
         // 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;
     }
-} );
\ No newline at end of file
+} );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iafa8d3213c9b824d8c6ebffd22a1b4b34fe38709
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: Mholloway <mhollo...@wikimedia.org>

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

Reply via email to