Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong char/word count if config.fullPage is set to true #43

Closed
catokolas opened this issue Jan 3, 2014 · 1 comment
Closed

Wrong char/word count if config.fullPage is set to true #43

catokolas opened this issue Jan 3, 2014 · 1 comment

Comments

@catokolas
Copy link

The additional html/head/body results in wrong count both for words and chars.

I've fixed it here by extracting the body content with search and substring, but there may be better ways of fixing it.

var i = text.search(new RegExp("<body>", "i"));
if (i != -1) {
  var j = text.search(new RegExp("</body>", "i"));
  text = text.substring(i+6, j);
}
...
if (normalizedText.trim().length) {
   normalizedText = strip(normalizedText);
   wordCount = normalizedText.split(/\s+/).length;
}
@w8tcha
Copy link
Owner

w8tcha commented Jan 5, 2014

thanks

@w8tcha w8tcha closed this as completed in c01ebc9 Jan 5, 2014
drupal-ckeditor-libraries-group-machine pushed a commit to drupal-ckeditor-libraries-group/CKEditor-WordCount-Plugin that referenced this issue May 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants