WIP: blank out label commands before running spell-check

This commit is contained in:
Shane Kilkelly 2017-06-16 09:20:35 +01:00
parent 1ecabaa611
commit a1d2d5b313

View file

@ -53,6 +53,9 @@ define [
@$scope.learnWord = (highlight) => @$scope.learnWord = (highlight) =>
@learnWord(highlight) @learnWord(highlight)
# DEBUG
window.BLANK = @blankOutBlacklistedCommands
runFullCheck: () -> runFullCheck: () ->
@highlightedWordManager.clearRows() @highlightedWordManager.clearRows()
if @$scope.spellCheckLanguage and @$scope.spellCheckLanguage != "" if @$scope.spellCheckLanguage and @$scope.spellCheckLanguage != ""
@ -217,6 +220,7 @@ define [
words = [] words = []
positions = [] positions = []
for line, row in lines for line, row in lines
line = @blankOutBlacklistedCommands(line)
if !linesToProcess? or linesToProcess[row] if !linesToProcess? or linesToProcess[row]
# Regex generated from /\\?['\p{L}]+/g via https://mothereff.in/regexpu. # Regex generated from /\\?['\p{L}]+/g via https://mothereff.in/regexpu.
# \p{L} matches unicode characters in the 'letter' category, but is not supported until ES6. # \p{L} matches unicode characters in the 'letter' category, but is not supported until ES6.
@ -246,3 +250,10 @@ define [
error: (xhr, status, error) -> error: (xhr, status, error) ->
callback error callback error
return $.ajax options return $.ajax options
blankOutBlacklistedCommands: (line) ->
line.replace /\\label(\[[^\]]*\])?{[^}]*}/g, (command) ->
command = command.replace /{.*}/, (args) ->
'{' + args.slice(1, args.length-1).split('').map((_char)-> '.').join('') + '}'
command.replace /\[.*\]/, (args) ->
'[' + args.slice(1, args.length-1).split('').map((_char)-> '.').join('') + ']'