Просмотр исходного кода

Extend, and clean up the command-matching regex

Shane Kilkelly 9 лет назад
Родитель
Сommit
0163ffc4bd

+ 15 - 1
services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.coffee

@@ -252,7 +252,21 @@ define [
 			return $.ajax options
 			return $.ajax options
 
 
 		blankOutBlacklistedCommands: (line) ->
 		blankOutBlacklistedCommands: (line) ->
-			line.replace /\\(label|ref|usepackage|begin|end)(\[[^\]]*\])?{[^}]*}/g, (command) ->
+			commandRegex = ///
+				\\                    # initial backslash
+				(label                # any of these commands
+				|[a-z]{0,2}ref
+				|usepackage
+				|begin
+				|end
+				|[a-z]{0,2}cite
+				|input
+				|include
+				|includegraphics)
+				( \[ [^\]]* \] )?     # optional [...] args
+				  \{ [^}]*  \}        # the {...} args
+			///g
+			line.replace commandRegex, (command) ->
 				command.replace(
 				command.replace(
 					/{.*}/, (args) ->
 					/{.*}/, (args) ->
 						'{' + args.slice(1, args.length-1).split('').map((_char)-> '.').join('') + '}'
 						'{' + args.slice(1, args.length-1).split('').map((_char)-> '.').join('') + '}'