Explorar o código

WIP: blank out label commands before running spell-check

Shane Kilkelly %!s(int64=9) %!d(string=hai) anos
pai
achega
a1d2d5b313

+ 11 - 0
services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.coffee

@@ -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('') + ']'