@ -95,14 +95,15 @@ end
mutable struct TEX < : SaveType
filename : : AbstractString
include_preamble : : Bool
TEX ( filename : : AbstractString ; include_preamble : : Bool = true ) = new ( removeExtension ( filename , " . t e x " ) , include_preamble )
limit_to : : Symbol
TEX ( filename : : AbstractString ; include_preamble : : Bool = true , limit_to : : Symbol = ( include_preamble ? : all : : picture ) ) =
new ( removeExtension ( filename , " . t e x " ) , limit_to )
end
mutable struct TIKZ < : SaveType
filename : : AbstractString
include_preamble : : Bo ol
TIKZ ( filename : : AbstractString ) = new ( removeExtension ( filename , " . t i k z " ) , false )
limit_to : : Symb ol
TIKZ ( filename : : AbstractString ) = new ( removeExtension ( filename , " . t i k z " ) , : all )
end
mutable struct SVG < : SaveType
@ -115,35 +116,44 @@ extension(f::SaveType) = lowercase(split("$(typeof(f))",".")[end])
showable ( : : MIME " i m a g e / s v g + x m l " , tp : : TikzPicture ) = true
function save ( f : : Union { TEX , TIKZ } , tp : : TikzPicture )
if ! in ( f . limit_to , [ : all , : picture , : data ] )
throw ( ArgumentError ( " l i m i t _ t o m u s t b e o n e o f : a l l , : p i c t u r e , a n d : d a t a " ) )
end
filename = f . filename
ext = extension ( f )
tex = open ( " $ ( filename ) . $ ( ext ) " , " w " )
if f . include_preamble
if standaloneWorkaround ( )
println ( tex , " \\ R e q u i r e P a c k a g e { l u a t e x 8 5 } " )
if f . limit_to in [ : all , : picture ]
if f . limit_to = = : all
if standaloneWorkaround ( )
println ( tex , " \\ R e q u i r e P a c k a g e { l u a t e x 8 5 } " )
end
println ( tex , " \\ d o c u m e n t c l a s s [ t i k z ] { s t a n d a l o n e } " )
println ( tex , tp . preamble )
println ( tex , " \\ b e g i n { d o c u m e n t } " )
end
println ( tex , " \\ d o c u m e n t c l a s s [ t i k z ] { s t a n d a l o n e } " )
println ( tex , tp . preamble )
println ( tex , " \\ b e g i n { d o c u m e n t } " )
print ( tex , " \\ b e g i n { t i k z p i c t u r e } [ " )
print ( tex , tp . options )
println ( tex , " ] " )
end
print ( tex , " \\ b e g i n { t i k z p i c t u r e } [ " )
print ( tex , tp . options )
println ( tex , " ] " )
println ( tex , tp . data )
println ( tex , " \\ e n d { t i k z p i c t u r e } " )
if f . include_preamble
println ( tex , " \\ e n d { d o c u m e n t } " )
if f . limit_to in [ : all , : picture ]
println ( tex , " \\ e n d { t i k z p i c t u r e } " )
if f . limit_to = = : all
println ( tex , " \\ e n d { d o c u m e n t } " )
end
end
close ( tex )
end
function save ( f : : TEX , td : : TikzDocument )
if isempty ( td . pictures )
error ( " T i k z D o c u m e n t d o e s n o t c o n t a i n p i c t u r e s " )
throw ( ArgumentError ( " T i k z D o c u m e n t d o e s n o t c o n t a i n p i c t u r e s " ) )
elseif ! in ( f . limit_to , [ : all , : picture ] )
throw ( ArgumentError ( " l i m i t _ t o m u s t b e e i t h e r : a l l o r : p i c t u r e " ) )
end
filename = f . filename
tex = open ( " $ ( filename ) . t e x " , " w " )
if f . include_preamble
if f . limit_to = = : all
println ( tex , " \\ d o c u m e n t c l a s s { a r t i c l e } " )
println ( tex , " \\ u s e p a c k a g e { c a p t i o n } " )
println ( tex , " \\ u s e p a c k a g e { t i k z } " )
@ -167,7 +177,7 @@ function save(f::TEX, td::TikzDocument)
println ( tex )
i += 1
end
if f . include_preamble
if f . limit_to = = : all
println ( tex , " \\ e n d { d o c u m e n t } " )
end
close ( tex )