Arlolra has uploaded a new change for review.
https://gerrit.wikimedia.org/r/232890
Change subject: Only and actually makeSepIndentPreSafe when necessary
......................................................................
Only and actually makeSepIndentPreSafe when necessary
Change-Id: I5c5b85b2283ea05fe06faff1441a28560ce2f730
---
M lib/wts.separators.js
1 file changed, 25 insertions(+), 14 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/90/232890/1
diff --git a/lib/wts.separators.js b/lib/wts.separators.js
index 3f706f6..ea40c71 100644
--- a/lib/wts.separators.js
+++ b/lib/wts.separators.js
@@ -509,20 +509,31 @@
var stripLeadingSpace = constraintInfo.onSOL && nodeB &&
Consts.SolSpaceSensitiveTags.has(nodeB.nodeName);
if (!isIndentPreSafe || stripLeadingSpace) {
- // Wrap non-nl ws from last line, but preserve comments.
- // This avoids triggering indent-pres.
- sep = sep.replace(WS_COMMENTS_SEP_REPLACE_REGEXP,
function() {
- var rest = arguments[2] || '';
- if (stripLeadingSpace) {
- // No other option but to strip the
leading space
- return rest;
- } else {
- // Since we nowiki-ed, we are no longer
in sol state
- state.onSOL = false;
- state.hasIndentPreNowikis = true;
- return '<nowiki>' + arguments[1] +
'</nowiki>' + rest;
- }
- });
+ var first = '';
+ var last = sep;
+ var sol = state.onSOL;
+ var parts = sep.split(/\n(?=[^\n]*$)/);
+ if (parts.length === 2) {
+ first = parts[0] + '\n';
+ last = parts[1];
+ sol = true;
+ }
+ if (sol) {
+ // Wrap non-nl ws from last line, but preserve
comments.
+ // This avoids triggering indent-pres.
+ sep = first +
last.replace(WS_COMMENTS_SEP_REPLACE_REGEXP, function() {
+ var rest = arguments[2] || '';
+ if (stripLeadingSpace) {
+ // No other option but to strip
the leading space
+ return rest;
+ } else {
+ // Since we nowiki-ed, we are
no longer in sol state
+ state.onSOL = false;
+ state.hasIndentPreNowikis =
true;
+ return '<nowiki>' +
arguments[1] + '</nowiki>' + rest;
+ }
+ });
+ }
}
}
--
To view, visit https://gerrit.wikimedia.org/r/232890
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5c5b85b2283ea05fe06faff1441a28560ce2f730
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits