mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-14 22:35:25 +00:00
Extend, and clean up the command-matching regex
This commit is contained in:
parent
1d905bd5ff
commit
0163ffc4bd
1 changed files with 15 additions and 1 deletions
|
@ -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('') + '}'
|
||||
|
|
Loading…
Add table
Reference in a new issue