diff options
author | Jesse Hallett <jesse@galois.com> | 2013-12-18 15:01:36 -0800 |
---|---|---|
committer | Jesse Hallett <jesse@galois.com> | 2013-12-18 15:01:36 -0800 |
commit | 29869e418f1322966b78bf546e6bdd13f2f28712 (patch) | |
tree | 44c89cd2edd492a0419f5de989d30e2525ae5dcd /guidelines/wikipedia/paragraphLength.js | |
parent | a53dea1deb469763a6f1754a72bfb8444942ac0d (diff) |
Wikipedia guideline: minimize number of single-sentence paragraphs
Diffstat (limited to 'guidelines/wikipedia/paragraphLength.js')
-rw-r--r-- | guidelines/wikipedia/paragraphLength.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/guidelines/wikipedia/paragraphLength.js b/guidelines/wikipedia/paragraphLength.js new file mode 100644 index 0000000..ba20306 --- /dev/null +++ b/guidelines/wikipedia/paragraphLength.js @@ -0,0 +1,15 @@ +exports.name = "Avoid single-sentence paragraphs"; +exports.description = "The number of single-sentence paragraphs should be minimized."; + +exports.rule = function(report) { + var sentenceBoundary = /[.?!](?:(?:\[\d+\])|['"])*(?:\s|$)/gm; + + $5('#mw-content-text p').each(function(i, p) { + var $p = $(p); + var text = $.trim($p.text()); + var boundaries = text && text.match(sentenceBoundary); + if (boundaries && boundaries.length === 1) { + report.warning('Paragraph with only one sentence: "' + text +'"', p); + } + }); +}; |