mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-31 22:51:44 +00:00
check for \tikzexternalize directly
instead of \usepackage{tikz} and \usepackage{pgf}
This commit is contained in:
parent
1273a05ad4
commit
dd35c5d88b
2 changed files with 12 additions and 19 deletions
|
@ -21,11 +21,9 @@ module.exports = TikzManager =
|
||||||
return false
|
return false
|
||||||
|
|
||||||
_includesTikz: (resource) ->
|
_includesTikz: (resource) ->
|
||||||
# check if we are loading tikz or pgf
|
# check if we are using tikz externalize
|
||||||
content = resource.content.slice(0,4096)
|
content = resource.content.slice(0,65536)
|
||||||
if content.indexOf("\\usepackage{tikz") >= 0
|
if content.indexOf("\\tikzexternalize") >= 0
|
||||||
return true
|
|
||||||
else if content.indexOf("\\usepackage{pgf") >= 0
|
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -11,28 +11,22 @@ describe 'TikzManager', ->
|
||||||
"logger-sharelatex": @logger = {log: () ->}
|
"logger-sharelatex": @logger = {log: () ->}
|
||||||
|
|
||||||
describe "needsOutputFile", ->
|
describe "needsOutputFile", ->
|
||||||
it "should return true if there is a usepackage{tikz}", ->
|
it "should return true if there is a \\tikzexternalize", ->
|
||||||
|
@TikzManager.needsOutputFile("main.tex", [
|
||||||
|
{ path: 'foo.tex' },
|
||||||
|
{ path: 'main.tex', content:'foo \\usepackage{tikz} \\tikzexternalize' }
|
||||||
|
]).should.equal true
|
||||||
|
|
||||||
|
it "should return false if there is no \\tikzexternalize", ->
|
||||||
@TikzManager.needsOutputFile("main.tex", [
|
@TikzManager.needsOutputFile("main.tex", [
|
||||||
{ path: 'foo.tex' },
|
{ path: 'foo.tex' },
|
||||||
{ path: 'main.tex', content:'foo \\usepackage{tikz}' }
|
{ path: 'main.tex', content:'foo \\usepackage{tikz}' }
|
||||||
]).should.equal true
|
|
||||||
|
|
||||||
it "should return true if there is a usepackage{pgf}", ->
|
|
||||||
@TikzManager.needsOutputFile("main.tex", [
|
|
||||||
{ path: 'foo.tex'},
|
|
||||||
{ path: 'main.tex', content:'foo \\usepackage{pgf}' }
|
|
||||||
]).should.equal true
|
|
||||||
|
|
||||||
it "should return false if there is no usepackage{tikz} or {pgf}", ->
|
|
||||||
@TikzManager.needsOutputFile("main.tex", [
|
|
||||||
{ path: 'foo.tex' },
|
|
||||||
{ path: 'main.tex', content:'foo \\usepackage{bar}' }
|
|
||||||
]).should.equal false
|
]).should.equal false
|
||||||
|
|
||||||
it "should return false if there is already an output.tex file", ->
|
it "should return false if there is already an output.tex file", ->
|
||||||
@TikzManager.needsOutputFile("main.tex", [
|
@TikzManager.needsOutputFile("main.tex", [
|
||||||
{ path: 'foo.tex' },
|
{ path: 'foo.tex' },
|
||||||
{ path: 'main.tex' },
|
{ path: 'main.tex', content:'foo \\usepackage{tikz} \\tikzexternalize' },
|
||||||
{ path: 'output.tex' }
|
{ path: 'output.tex' }
|
||||||
]).should.equal false
|
]).should.equal false
|
||||||
|
|
||||||
|
@ -44,6 +38,7 @@ describe 'TikzManager', ->
|
||||||
@content = '''
|
@content = '''
|
||||||
\\documentclass{article}
|
\\documentclass{article}
|
||||||
\\usepackage{tikz}
|
\\usepackage{tikz}
|
||||||
|
\\tikzexternalize
|
||||||
\\begin{document}
|
\\begin{document}
|
||||||
Hello world
|
Hello world
|
||||||
\\end{document}
|
\\end{document}
|
||||||
|
|
Loading…
Reference in a new issue