From ff0f961df50651dfa7ee95e2374d20003bb56272 Mon Sep 17 00:00:00 2001 From: Jesse Hallett Date: Wed, 18 Dec 2013 15:44:35 -0800 Subject: Wikipedia guideline: there should only be one blank line between paragraphs --- guidelines/wikipedia/spaceBetweenParagraphs.js | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 guidelines/wikipedia/spaceBetweenParagraphs.js (limited to 'guidelines/wikipedia/spaceBetweenParagraphs.js') diff --git a/guidelines/wikipedia/spaceBetweenParagraphs.js b/guidelines/wikipedia/spaceBetweenParagraphs.js new file mode 100644 index 0000000..ccab3a4 --- /dev/null +++ b/guidelines/wikipedia/spaceBetweenParagraphs.js @@ -0,0 +1,28 @@ +exports.name = "There should only be one blank line between paragraphs"; +exports.description = "Between sections - as between sections - there should be only a single blank line."; + +exports.rule = function(report) { + var problemPs = []; + + $5('p:has(> br)').each(function(i, p) { + var $p = $(p), prevP; + if ($.trim($p.text()).length === 0) { + prevP = $p.prevAll('p').filter(function(i, pp) { + return $.trim($(pp).text()).length > 0; + }).first(); + + if (prevP.length) { + problemPs.push(prevP.get(0)); + } + else { + report.error('Paragraph contains line breaks but does not contain text.', p); + } + } + }); + + _.uniq(problemPs, false).forEach(function(p) { + var text = $.trim($(p).text()); + report.error('Paragraph is followed by more than one blank line: '+ text, p); + }); +}; + -- cgit v1.2.3