Extend, and clean up the command-matching regex

This commit is contained in:
Shane Kilkelly 2017-06-16 10:17:30 +01:00
parent 1d905bd5ff
commit 0163ffc4bd

View file

@ -252,7 +252,21 @@ define [
return $.ajax options
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(
/{.*}/, (args) ->
'{' + args.slice(1, args.length-1).split('').map((_char)-> '.').join('') + '}'