CheckLexLine returns the Lex regions for any words that are misspelled within given line of text with existing Lex tags -- automatically excludes any Code token regions (see token.IsCode). Token is set to token.TextSpellErr on returned Lex's
(src []rune, tags lexer.Line)
| 16 | // excludes any Code token regions (see token.IsCode). Token is set |
| 17 | // to token.TextSpellErr on returned Lex's |
| 18 | func CheckLexLine(src []rune, tags lexer.Line) lexer.Line { |
| 19 | wrds := tags.NonCodeWords(src) |
| 20 | var ser lexer.Line |
| 21 | for _, t := range wrds { |
| 22 | wrd := string(t.Src(src)) |
| 23 | lwrd := lexer.FirstWordApostrophe(wrd) |
| 24 | if len(lwrd) <= 2 { |
| 25 | continue |
| 26 | } |
| 27 | _, known := Spell.CheckWord(lwrd) |
| 28 | if !known { |
| 29 | t.Token.Token = token.TextSpellErr |
| 30 | widx := strings.Index(wrd, lwrd) |
| 31 | ld := len(wrd) - len(lwrd) |
| 32 | t.St += widx |
| 33 | t.Ed += widx - ld |
| 34 | t.Now() |
| 35 | ser = append(ser, t) |
| 36 | } |
| 37 | } |
| 38 | return ser |
| 39 | } |
no test coverage detected