Move command-matching regex to the class level

This commit is contained in:
Shane Kilkelly 2017-06-16 10:20:55 +01:00
parent 0163ffc4bd
commit 85ddff15cb

View file

@ -251,8 +251,7 @@ define [
callback error callback error
return $.ajax options return $.ajax options
blankOutBlacklistedCommands: (line) -> blacklistedCommandRegex: ///
commandRegex = ///
\\ # initial backslash \\ # initial backslash
(label # any of these commands (label # any of these commands
|[a-z]{0,2}ref |[a-z]{0,2}ref
@ -266,7 +265,9 @@ define [
( \[ [^\]]* \] )? # optional [...] args ( \[ [^\]]* \] )? # optional [...] args
\{ [^}]* \} # the {...} args \{ [^}]* \} # the {...} args
///g ///g
line.replace commandRegex, (command) ->
blankOutBlacklistedCommands: (line) ->
line.replace @blacklistedCommandRegex, (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('') + '}'