diff options
author | Jesse Hallett <jesse@galois.com> | 2013-12-18 15:44:35 -0800 |
---|---|---|
committer | Jesse Hallett <jesse@galois.com> | 2013-12-18 16:07:48 -0800 |
commit | ff0f961df50651dfa7ee95e2374d20003bb56272 (patch) | |
tree | 4362f1bb804c6f78587433763e8da51393a422b9 | |
parent | 29869e418f1322966b78bf546e6bdd13f2f28712 (diff) |
Wikipedia guideline: there should only be one blank line between paragraphs
-rw-r--r-- | guidelines/wikipedia/spaceBetweenParagraphs.js | 28 | ||||
-rw-r--r-- | guidelines/wikipedia/wikipedia.json | 1 |
2 files changed, 29 insertions, 0 deletions
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); + }); +}; + diff --git a/guidelines/wikipedia/wikipedia.json b/guidelines/wikipedia/wikipedia.json index 3150c5e..ee641b6 100644 --- a/guidelines/wikipedia/wikipedia.json +++ b/guidelines/wikipedia/wikipedia.json @@ -6,6 +6,7 @@ , "bullets.js" , "strikeout.js" , "color.js" + , "spaceBetweenParagraphs.js" , "paragraphLength.js" ] } |