aboutsummaryrefslogtreecommitdiff
path: root/guidelines/wikipedia/paragraphLength.js
diff options
context:
space:
mode:
authorGravatar Rogan Creswick <creswick@gmail.com>2013-12-19 13:31:29 -0800
committerGravatar Rogan Creswick <creswick@gmail.com>2013-12-19 13:31:29 -0800
commitaa2a7b34b64be8daf1a9d50f589563275284d50e (patch)
treeda898aabcbca0191a57140e635e167b88aaa84e0 /guidelines/wikipedia/paragraphLength.js
parent3b53cef842cf0288ad55fe55ae2f578f75b40ae7 (diff)
parent15a644f91a8b6e80bbd24a824b91c24547b80035 (diff)
merge
Diffstat (limited to 'guidelines/wikipedia/paragraphLength.js')
-rw-r--r--guidelines/wikipedia/paragraphLength.js15
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);
+ }
+ });
+};