From a1d2d5b313e97ef02dda57bb88e27284f5b288a8 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Fri, 16 Jun 2017 09:20:35 +0100 Subject: [PATCH] WIP: blank out label commands before running spell-check --- .../aceEditor/spell-check/SpellCheckManager.coffee | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.coffee index 759b1d2b70..d4008b0bcd 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.coffee @@ -53,6 +53,9 @@ define [ @$scope.learnWord = (highlight) => @learnWord(highlight) + # DEBUG + window.BLANK = @blankOutBlacklistedCommands + runFullCheck: () -> @highlightedWordManager.clearRows() if @$scope.spellCheckLanguage and @$scope.spellCheckLanguage != "" @@ -217,6 +220,7 @@ define [ words = [] positions = [] for line, row in lines + line = @blankOutBlacklistedCommands(line) if !linesToProcess? or linesToProcess[row] # 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. @@ -246,3 +250,10 @@ define [ error: (xhr, status, error) -> callback error 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('') + ']'