[MediaWiki-commits] [Gerrit] Followup on stripping trailing s to retain valid uses - change (mediawiki...parsoid)
jenkins-bot has submitted this change and it was merged. Change subject: Followup on stripping trailing s to retain valid uses .. Followup on stripping trailing s to retain valid uses * Transclusions can have trailing when it is a valid template argument being passed in. * Eliminates selser diffs seen during roundtrip testing. Change-Id: I08c7b8b204d4a80c27efbefe8ef08efd7034c4c9 --- M lib/html2wt/WikitextSerializer.js M tests/parserTests.txt 2 files changed, 17 insertions(+), 2 deletions(-) Approvals: Arlolra: Looks good to me, approved Subramanya Sastry: Looks good to me, but someone else must approve jenkins-bot: Verified diff --git a/lib/html2wt/WikitextSerializer.js b/lib/html2wt/WikitextSerializer.js index 84ab7d2..ab9ca8f 100644 --- a/lib/html2wt/WikitextSerializer.js +++ b/lib/html2wt/WikitextSerializer.js @@ -1235,7 +1235,13 @@ if (state.hasSelfClosingNowikis || state.selserMode) { // Strip (useless) trailing s // Interim fix till we stop introducing them in the first place. - state.out = state.out.replace(/(?:)+($|\n)/g, '$1'); + // + // Don't strip |param = since that pattern is used + // in transclusions and where the trailing is a valid + // template arg. So, use a conservative regexp to detect that usage. + state.out = state.out.split('\n').map(function(piece) { + return piece.replace(/^([^=]*?)(?:\s*)+$/, '$1'); + }).join('\n'); } return state.out; diff --git a/tests/parserTests.txt b/tests/parserTests.txt index 3bdcb11..c28c008 100644 --- a/tests/parserTests.txt +++ b/tests/parserTests.txt @@ -26274,15 +26274,24 @@ # This is meant to be an interim fix while we go about figuring out # how to not introduce these trailing s in the first place. !! test -T115717: Strip trailing s +T115717: Strip trailing s (without affecting valid uses) !! options parsoid=html2wt !! html/parsoid x y + + !! wikitext x y + +{{echo| +1 = }} + +{{echo| +1 = +}} !! end # --- -- To view, visit https://gerrit.wikimedia.org/r/254906 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I08c7b8b204d4a80c27efbefe8ef08efd7034c4c9 Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Subramanya Sastry Gerrit-Reviewer: Arlolra Gerrit-Reviewer: Cscott Gerrit-Reviewer: Subramanya Sastry Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Followup on stripping trailing s to retain valid uses - change (mediawiki...parsoid)
Subramanya Sastry has uploaded a new change for review. https://gerrit.wikimedia.org/r/254906 Change subject: Followup on stripping trailing s to retain valid uses .. Followup on stripping trailing s to retain valid uses * Transclusions can have trailing when it is a valid template argument being passed in. * Eliminates selser diffs seen during roundtrip testing. Change-Id: I08c7b8b204d4a80c27efbefe8ef08efd7034c4c9 --- M lib/html2wt/WikitextSerializer.js M tests/parserTests.txt 2 files changed, 17 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid refs/changes/06/254906/1 diff --git a/lib/html2wt/WikitextSerializer.js b/lib/html2wt/WikitextSerializer.js index 003bfff..73bbab5 100644 --- a/lib/html2wt/WikitextSerializer.js +++ b/lib/html2wt/WikitextSerializer.js @@ -1194,7 +1194,13 @@ if (state.hasSelfClosingNowikis || state.selserMode) { // Strip (useless) trailing s // Interim fix till we stop introducing them in the first place. - state.out = state.out.replace(/(?:)+($|\n)/g, '$1'); + // + // Don't strip |param = since that pattern is used + // in transclusions and where the trailing is a valid + // template arg. So, use a conservative regexp to detect that usage. + state.out = state.out.split('\n').map(function(piece) { + return piece.replace(/^([^=]*?(?![^=]*=\s*))(?:)+(\s*$)/g, '$1'); + }).join('\n'); } return state.out; diff --git a/tests/parserTests.txt b/tests/parserTests.txt index 3bdcb11..c28c008 100644 --- a/tests/parserTests.txt +++ b/tests/parserTests.txt @@ -26274,15 +26274,24 @@ # This is meant to be an interim fix while we go about figuring out # how to not introduce these trailing s in the first place. !! test -T115717: Strip trailing s +T115717: Strip trailing s (without affecting valid uses) !! options parsoid=html2wt !! html/parsoid x y + + !! wikitext x y + +{{echo| +1 = }} + +{{echo| +1 = +}} !! end # --- -- To view, visit https://gerrit.wikimedia.org/r/254906 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I08c7b8b204d4a80c27efbefe8ef08efd7034c4c9 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Subramanya Sastry ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits