mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
22 lines
547 B
CoffeeScript
22 lines
547 B
CoffeeScript
define [
|
|
"base"
|
|
], (App) ->
|
|
|
|
App.factory 'preamble', (ide) ->
|
|
|
|
Preamble =
|
|
getPreambleText: () ->
|
|
text = ide.editorManager.getCurrentDocValue().slice(0, 5000)
|
|
preamble = text.match(/([^]*)^\\begin\{document\}/m)?[1] || ""
|
|
return preamble
|
|
|
|
getGraphicsPaths: () ->
|
|
preamble = Preamble.getPreambleText()
|
|
graphicsPathsArgs = preamble.match(/\\graphicspath\{(.*)\}/)?[1] || ""
|
|
paths = []
|
|
re = /\{([^}]*)\}/g
|
|
while match = re.exec(graphicsPathsArgs)
|
|
paths.push(match[1])
|
|
return paths
|
|
|
|
return Preamble
|