mdspell 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +21 -0
- data/lib/mdspell/cli.rb +9 -1
- data/lib/mdspell/configuration.rb +1 -0
- data/lib/mdspell/spell_checker.rb +20 -1
- data/lib/mdspell/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9486da2132f09b67ecc6d79b83a5701c5838dae7
|
4
|
+
data.tar.gz: 464a9061d93316b14d71e59dc4486193ef58dba5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8decde7a93905b67e6851aeca803ec8c5435c990d78c961318891bd23603b8ee612f175867971e32c93917f01b9788236fe6cb7e6979aee15ec98f175913940
|
7
|
+
data.tar.gz: 319d66b9266d9c460b5d814a405f3f027b36a7bfd213786904cb8dddff87da8b9b4c30859d02c41c687120f1e309b3a738fc0cf022c80792e609b2fe4499cf3b
|
data/README.md
CHANGED
@@ -51,6 +51,27 @@ spec/examples/with_errors.md:5: tobe
|
|
51
51
|
spec/examples/complete.md:24: Unordered
|
52
52
|
```
|
53
53
|
|
54
|
+
### Ignore lists
|
55
|
+
|
56
|
+
In some cases, there may be words that are legitimately not in the dictionary you are using because they are proper nouns, or obscure technical terms.
|
57
|
+
|
58
|
+
You may specify words (or even regular expressions) to ignore via the --ignored flag:
|
59
|
+
|
60
|
+
```
|
61
|
+
mdspell README.md --ignored config,mdspell,ruby.*,file.ame
|
62
|
+
```
|
63
|
+
|
64
|
+
Likewise, you may specify this in a config file
|
65
|
+
|
66
|
+
```
|
67
|
+
ignored:
|
68
|
+
- expr1
|
69
|
+
- word2
|
70
|
+
...
|
71
|
+
```
|
72
|
+
|
73
|
+
Please note that you should take care to use non-greedy, precise, regular expressions as to not mask legitimate spelling errors.
|
74
|
+
|
54
75
|
## MIT Licensed
|
55
76
|
|
56
77
|
See [LICENSE](https://github.com/mtuchowski/mdspell/blob/master/LICENSE) file for full license
|
data/lib/mdspell/cli.rb
CHANGED
@@ -17,6 +17,12 @@ module MdSpell
|
|
17
17
|
long: '--language LANG',
|
18
18
|
description: 'Set documents language'
|
19
19
|
|
20
|
+
option :ignored,
|
21
|
+
short: '-i IGNORED1,IGNORED2,...',
|
22
|
+
long: '--ignored IGNORED1,IGNORED2,...',
|
23
|
+
description: 'CSV of expressions to be ignored',
|
24
|
+
proc: proc { |csv| csv.split(',') }
|
25
|
+
|
20
26
|
option :verbose,
|
21
27
|
short: '-v',
|
22
28
|
long: '--[no-]verbose',
|
@@ -35,8 +41,10 @@ module MdSpell
|
|
35
41
|
def run(options)
|
36
42
|
raise ArgumentError, 'expected Array of command line options' unless options.is_a? Array
|
37
43
|
|
38
|
-
|
44
|
+
# Start clean
|
45
|
+
MdSpell::Configuration.reset
|
39
46
|
|
47
|
+
parse_options(options)
|
40
48
|
# Load optional config file if it's present.
|
41
49
|
if config[:config_file]
|
42
50
|
config_filename = File.expand_path(config[:config_file])
|
@@ -29,10 +29,10 @@ module MdSpell
|
|
29
29
|
# Returns found spelling errors.
|
30
30
|
def typos
|
31
31
|
results = []
|
32
|
-
|
33
32
|
FFI::Aspell::Speller.open(Configuration[:language]) do |speller|
|
34
33
|
TextLine.scan(document).each do |line|
|
35
34
|
line.words.each do |word|
|
35
|
+
next if ignored? word
|
36
36
|
unless speller.correct? word
|
37
37
|
results << Typo.new(line, word, speller.suggestions(word))
|
38
38
|
end
|
@@ -42,5 +42,24 @@ module MdSpell
|
|
42
42
|
|
43
43
|
results
|
44
44
|
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def ignored?(word)
|
49
|
+
# For each ignored word / expression, join them together with
|
50
|
+
# An atomic grouping:
|
51
|
+
# http://ruby-doc.org/core-2.1.1/Regexp.html#class-Regexp-label-Atomic+Grouping
|
52
|
+
# And an alternation using the '|' character:
|
53
|
+
# http://ruby-doc.org/core-2.1.1/Regexp.html#class-Regexp-label-Alternation
|
54
|
+
# Compile it the result into a single regular expression,
|
55
|
+
# and save it as an instance variable so we don't need to recompile.
|
56
|
+
return false if Configuration[:ignored].empty?
|
57
|
+
@ignored ||= begin
|
58
|
+
Regexp.new(Configuration[:ignored].map do |e|
|
59
|
+
"(?>#{e})"
|
60
|
+
end.join('|'), Regexp::EXTENDED | Regexp::IGNORECASE)
|
61
|
+
end
|
62
|
+
@ignored =~ word
|
63
|
+
end
|
45
64
|
end
|
46
65
|
end
|
data/lib/mdspell/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mdspell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marek Tuchowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|