Skip to content

Allow code spellcheck #2

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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions es5/markdown-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,17 @@ exports.default = function (src) {
if (jekyllFrontMatter) {
tracker.replaceAll(jekyllFrontMatter, " ");
}

tracker.removeAll(/```[\w\W]*?```/);
tracker.removeAll(/~~~[\w\W]*?~~~/);
tracker.replaceAll(/<code[\w\W]*?<\/code>/, " ");
tracker.removeAll(/``[\w\W]*?``/);
tracker.removeAll(/`[^`]*`/);
tracker.replaceAll(/<style[\w\W]*?<\/style>/, " "); // remove contents of style
tracker.replaceAll(/<script[\w\W]*?<\/script>/, " "); // remove contents of scripts
tracker.replaceAll(/\{%\s*highlight[\w\W]*?\{%\s*endhighlight\s*%\}/, " "); // remove contents code blocks
tracker.replaceAll(/\{%.*%\}/, " ");
tracker.replaceAll(/\{\{.*\}\}/, " ");
tracker.replaceAll(/&[#a-z0-9]{1,5};/, " ");
src = tracker.replaceAll(/<\/?[a-z0-9]+ ?([a-z]+="[^"]*" ?)*\/?>/i, " ");
src = src.split('`').join(' ');
src = src.split('-').join(' ');
src = src.split('#').join(' ');
src = src.split('_').join(' ');

var options = {
gfm: true,
Expand Down
3 changes: 0 additions & 3 deletions es5/spellcheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ function checkWord(word, options) {
if (spellchecker.check(word)) {
return true;
}
if (word.includes('Parse')) {
return true;
}

if (word.match(/'s$/)) {
var wordWithoutPlural = word.substr(0, word.length - 2);
Expand Down
11 changes: 10 additions & 1 deletion es5/word-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ exports.default = function (tokens) {
if (badEndings) {
word = word.substr(0, word.length - badEndings[0].length);
}
wordList.push({ word: word, index: thisWordIndex });
word = word.split('.').join(' ')
var wordTwo = word.replace(/([A-Z]+)*([A-Z][a-z])/g, "$1 $2");
var wordSplit = wordTwo.split(' ')
for (var x=0;x<wordSplit.length;x++) {
var split = wordSplit[x];
if (split === '') {
continue;
}
wordList.push({ word: split, index: thisWordIndex + word.indexOf(split) });
}

index += nextWord.index + nextWord[0].length;
text = text.slice(nextWord.index + nextWord[0].length);
Expand Down
9 changes: 4 additions & 5 deletions es6/markdown-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@ export default function(src) {
tracker.replaceAll(jekyllFrontMatter, " ");
}

tracker.removeAll(/```[\w\W]*?```/);
tracker.removeAll(/~~~[\w\W]*?~~~/);
tracker.removeAll(/``[\w\W]*?``/);
tracker.removeAll(/`[^`]*`/);
tracker.replaceAll(/<style[\w\W]*?<\/style>/, " "); // remove contents of style
tracker.replaceAll(/<script[\w\W]*?<\/script>/, " "); // remove contents of scripts
tracker.replaceAll(/\{%\s*highlight[\w\W]*?\{%\s*endhighlight\s*%\}/, " "); // remove contents code blocks
tracker.replaceAll(/\{%.*%\}/, " ");
tracker.replaceAll(/\{\{.*\}\}/, " ");
tracker.replaceAll(/&[#a-z0-9]{1,5};/, " ");
src = tracker.replaceAll(/<\/?[a-z0-9]+ ?([a-z]+="[^"]*" ?)*\/?>/i, " ");
src = src.split('`').join(' ');
src = src.split('-').join(' ');
src = src.split('#').join(' ');
src = src.split('_').join(' ');

const options = {
gfm: true,
Expand Down
9 changes: 8 additions & 1 deletion es6/word-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ export default function(tokens) {
if (badEndings) {
word = word.substr(0, word.length - badEndings[0].length);
}
wordList.push({ word: word, index: thisWordIndex });
word = word.split('.').join(' ')
const wordTwo = word.replace(/([A-Z]+)*([A-Z][a-z])/g, "$1 $2");
for (const split of wordTwo.split(' ')) {
if (split === '') {
continue;
}
wordList.push({ word: split, index: thisWordIndex + word.indexOf(split) });
}

index += nextWord.index + nextWord[0].length;
text = text.slice(nextWord.index + nextWord[0].length);
Expand Down