diff options
Diffstat (limited to 'guidelines/wikipedia')
-rw-r--r-- | guidelines/wikipedia/paragraphLength.js | 15 | ||||
-rw-r--r-- | guidelines/wikipedia/wikipedia.json | 1 |
2 files changed, 16 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); + } + }); +}; diff --git a/guidelines/wikipedia/wikipedia.json b/guidelines/wikipedia/wikipedia.json index 17ed6c9..3150c5e 100644 --- a/guidelines/wikipedia/wikipedia.json +++ b/guidelines/wikipedia/wikipedia.json @@ -6,5 +6,6 @@ , "bullets.js" , "strikeout.js" , "color.js" + , "paragraphLength.js" ] } |