Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ep_readability

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ep_readability - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

test/test.js

17

package.json
{
"name": "ep_readability",
"version": "0.0.6",
"version": "0.0.7",
"description": "Calculates the FLESCH readability index, client based.",
"author": "Erik <ep_readability@web.de>",
"author": {
"name": "Erik",
"email": "ep_readability@web.de"
},
"contributors": [],
"dependencies": {},
"engines": { "node": ">= 0.6.0" }
}
"engines": {
"node": ">= 0.6.0"
},
"readme": "# 1 Click to calculate the FLESCH readability factor\r\nThere'll be a button. Push it.\r\n\r\nColours indicate the readability. \r\n\r\nNumeric values detail the readability:\r\n\r\na) Negative numbers or around \"0\" indicate texts which are very difficult to read.\r\n\r\nb) Numbers around \"100\" indicate very easy texts.\r\n\r\n# Install\r\n\r\nOn the command line, run `npm install ep_readability`.\r\n\r\nAlternatively, browse to `http://yourEtherpadliteInstan.ce/admin/plugins`, search for `ep_readability` and click install.\r\n\r\nAfter restarting the server, the plugin takes effect.\r\n\r\n# License\r\nMIT",
"readmeFilename": "README.md",
"_id": "ep_readability@0.0.6",
"_from": "ep_readability@"
}

@@ -12,2 +12,4 @@ # 1 Click to calculate the FLESCH readability factor

Calculating is triggered by editing action or by pushing the button.
# Install

@@ -14,0 +16,0 @@

@@ -11,3 +11,3 @@ // ----------------------------------------------------------------------------

function cleanText(text) {
exports.cleanText = function(text) {

@@ -17,4 +17,6 @@ // all these tags should be preceeded by a full stop.

fullStopTags.forEach(function(tag) {
text = text.replace("</" + tag + ">",'. ');
text = text.replace("</" + tag + ">",'.');
})
//console.log(text);

@@ -25,22 +27,27 @@ // This is Etherpad specific:

text = text.replace(/<span[^>]*>/gm,'').replace(/<\/span>/gm,'');
text = text.replace(/<div[^>]*class="ace-line"[^>]*>([^<]*[^,!?.])<\/div>/gm, "$1. ");
text = text.replace(/<div[^>]*>([^<]+[^:,!?.-])<\/div>/gm, "$1.");
// This is not Etherpad specific:
// @TODO Add URL matcher
text = text
.replace(/<[^>]+>/g, ' ') // Strip tags
.replace(/[!?]/g, '. ') // Unify terminators
.replace(/(\d+\.?,?)+/g, 'two ') // Convert numbers with delimiters to one syllable
.replace(/(\w)(\r\n|\n|\r)/gm,"$1. ") // Add dot to text followed by linebreak (probably a heading)
.replace(/<[^>]+>/gm, '') // Strip tags
.replace(/\d+([\.,]?\d+)*/g, 'two') // Convert numbers with delimiters to one syllable @TODO lookahead for space: EUR 1000. bla
.replace(/[!?]/gm, '.') // Unify terminators
.replace(/(\w)[:,](\S+)/gm, '$1 $2') // Unify sentence structure
.replace(/(\w)- (?!und|and)(\w)/gm, '$1$2') // Remove inline word breaks @TODO add other fill words
.replace(/(\w)(\r\n|\n|\r)/gm,"$1.") // Add dot to text followed by linebreak (probably a heading)
.replace(/(\r\n|\n|\r)/gm,' ') // Replace new lines with spaces
.replace(/[^a-zA-Z0-9\.äüöÄÜÖß ]+/g, '') // Remove non-word characters, removes "-", too!
.replace(/[^a-zA-Z0-9\.äüöÄÜÖß ]+/gm, '') // Remove non-word characters
.replace(/\s+/g,' ') // Remove multiple spaces
.replace(/^\s+/g,'') // Strip leading whitespace
.replace(/\s+$/g,'') // Strip trailing whitespace
.replace(/[\.]{2,}/,'.'); // Check for duplicated terminators
.replace(/^\s+/gm,'') // Strip leading whitespace
.replace(/\s+$/gm,'') // Strip trailing whitespace
.replace(/(\w)\.(\w)/gm,'$1. $2'); // Enhance readability
//console.log(text);
return text;
}
fleschReadingEase = function(text) {
exports.fleschReadingEase = function(text) {
var flesch = wordCount = sentenceCount = syllCount = averageWordsPerSentence = averageSyllablesPerWord = null;
text = cleanText(text);
text = exports.cleanText(text);

@@ -55,3 +62,3 @@ wordCount = text.split(/[\s\.]+/g).length || 1;

words += word + '_';
syllCount += syllableCount(word);
syllCount += exports.syllableCount(word);
});

@@ -78,3 +85,3 @@ averageSyllablesPerWord = (syllCount || 1) / wordCount;

//
syllableCount = function(word) {
exports.syllableCount = function(word) {

@@ -198,6 +205,6 @@ var syllableCount = 0,

// do not calculate index if no key has been pressed
var calculateInterval = null;
// do not calculate index if no key has been pressed
var calculateInterval = null;
exports.aceKeyEvent = function(hook, callstack) {
exports.aceKeyEvent = function(hook, callstack) {

@@ -221,3 +228,2 @@ // Avoiding recalculation of index if user is typing numbers and chars.

$('#calculateReadabilityButton').trigger('click');
//alert('click');
},1500);

@@ -233,3 +239,3 @@

$('#readabilityInfo').attr('title', toolTip);
setTimeout(function() {
calculateInterval = setTimeout(function() {
$('#calculateReadabilityButton').trigger('click');

@@ -251,3 +257,3 @@ }, 1500);

if(text.length > 0) {
result = fleschReadingEase( text );
result = exports.fleschReadingEase( text );
jQuery.each(colorOrder, function(index, item) {

@@ -254,0 +260,0 @@ //alert(result.flesch +" - "+ item)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc