Skip to content

Commit

Permalink
xfd: Add a newline after TfD if table
Browse files Browse the repository at this point in the history
Lack of a newline (wikimedia-gadgets#254) causes issues if the template is a table.  Closes wikimedia-gadgets#359.
  • Loading branch information
Amorymeltzer committed Mar 7, 2019
1 parent 43f9840 commit 40a4aee
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/twinklexfd.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,9 +715,10 @@ Twinkle.xfd.callbacks = {
taggingTemplate: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
var tableNewline = /^{\|/.test(text) ? '\n' : '';

pageobj.setPageText((params.noinclude ? "<noinclude>" : "") + "{{subst:template for discussion|help=off|" +
(params.tfdtype !== "standard" ? "type=" + params.tfdtype + "|" : "") + mw.config.get('wgTitle') + (params.noinclude ? "}}</noinclude>" : "}}") + text);
(params.tfdtype !== "standard" ? "type=" + params.tfdtype + "|" : "") + mw.config.get('wgTitle') + (params.noinclude ? "}}</noinclude>" : "}}") + tableNewline + text);
pageobj.setEditSummary("Nominated for deletion; see [[:" + params.logpage + "#" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
switch (Twinkle.getPref('xfdWatchPage')) {
case 'yes':
Expand All @@ -736,10 +737,11 @@ Twinkle.xfd.callbacks = {
taggingTemplateForMerge: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
var tableNewline = /^{\|/.test(text) ? '\n' : '';

pageobj.setPageText((params.noinclude ? "<noinclude>" : "") + "{{subst:tfm|help=off|" +
(params.tfdtype !== "standard" ? "type=" + params.tfdtype + "|" : "") + "1=" + params.otherTemplateName.replace(/^Template:/, "") +
(params.noinclude ? "}}</noinclude>" : "}}\n") + text);
(params.noinclude ? "}}</noinclude>" : "}}\n") + tableNewline + text);
pageobj.setEditSummary("Nominated for merging with [[:" + params.otherTemplateName + "]]; see [[:" +
params.logpage + "#" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
switch (Twinkle.getPref('xfdWatchPage')) {
Expand Down

0 comments on commit 40a4aee

Please sign in to comment.