Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
ModJuliaTikz.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Regler
ModJuliaTikz.jl
Commits
6ebc40df
Commit
6ebc40df
authored
1 year ago
by
Leif Andersson
Browse files
Options
Downloads
Patches
Plain Diff
Using include_string instead of include.
parent
0757000a
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Project.toml
+1
-1
1 addition, 1 deletion
Project.toml
src/ModJuliaTikz.jl
+26
-37
26 additions, 37 deletions
src/ModJuliaTikz.jl
with
27 additions
and
38 deletions
Project.toml
+
1
−
1
View file @
6ebc40df
name
=
"ModJuliaTikz"
name
=
"ModJuliaTikz"
uuid
=
"03fd23bd-cacd-4584-a80b-c389ae8a36ca"
uuid
=
"03fd23bd-cacd-4584-a80b-c389ae8a36ca"
authors
=
[
"Leif Andersson <leif.andersson@control.lth.se>"
]
authors
=
[
"Leif Andersson <leif.andersson@control.lth.se>"
]
version
=
"0.
1
.0"
version
=
"0.
2
.0"
[compat]
[compat]
julia
=
"1"
julia
=
"1"
...
...
This diff is collapsed.
Click to expand it.
src/ModJuliaTikz.jl
+
26
−
37
View file @
6ebc40df
...
@@ -44,9 +44,8 @@ function printcsv(data::Array{Any}, csv="")
...
@@ -44,9 +44,8 @@ function printcsv(data::Array{Any}, csv="")
end
end
end
end
"""
"""
JuliaTikz(tikzfile,
delete=tru
e)
JuliaTikz(tikzfile,
write_file=fals
e)
Extract and run the Julia part of a combined tikz/Julia file.
Extract and run the Julia part of a combined tikz/Julia file.
...
@@ -54,20 +53,12 @@ The boundary between the two is the string
...
@@ -54,20 +53,12 @@ The boundary between the two is the string
\\
endinput Julia <name>
\\
endinput Julia <name>
where `<name>` is the name that will be given to the Julia file
where `<name>` is the name that will be given to a variable `name`
(with .jl appended), and also to a variable `name` in the program,
in the program, and also to the Julia file (with .jl appended),
i.e. name = "
<
name
>
".
if the optional argument `write_file` is true.
The Julia file will be extracted to a temporary directory, which will be
deleted after the run unless the optional argument `delete` is false.
"""
"""
function
JuliaTikz
(
tikzfile
,
delete
=
true
)
function
JuliaTikz
(
tikzfile
,
write_file
=
false
)
dir
=
mktempdir
();
filespec
=
""
;
out
=
""
;
if
!
delete
println
(
"Opening "
*
tikzfile
)
end
;
open
(
tikzfile
)
do
file
open
(
tikzfile
)
do
file
res
=
nothing
;
res
=
nothing
;
while
res
===
nothing
while
res
===
nothing
...
@@ -79,28 +70,26 @@ function JuliaTikz(tikzfile,delete=true)
...
@@ -79,28 +70,26 @@ function JuliaTikz(tikzfile,delete=true)
end
;
end
;
global
name
=
res
.
captures
[
2
];
global
name
=
res
.
captures
[
2
];
filespec
=
join
([
dir
,
name
*
".jl"
],
"/"
);
global
progLines
=
String
[]
out
=
open
(
filespec
,
"w"
);
push!
(
progLines
,
"module "
*
name
*
"
\n
"
)
if
!
delete
push!
(
progLines
,
"import ..ModJuliaTikz: printcsv
\n
"
)
println
(
"Writing "
*
filespec
);
end
;
line
=
"module "
*
name
;
println
(
out
,
line
);
line
=
"import ..ModJuliaTikz: printcsv"
;
println
(
out
,
line
);
while
!
eof
(
file
)
while
!
eof
(
file
)
println
(
out
,
readline
(
file
));
push!
(
progLines
,
readline
(
file
;
keep
=
true
))
end
;
println
(
out
,
"end"
);
close
(
out
);
end
;
end
;
include
(
filespec
);
end
push!
(
progLines
,
"end
\n
"
)
if
delete
if
write_file
rm
(
dir
,
recursive
=
true
);
dir
=
mktempdir
();
else
filespec
=
join
([
dir
,
name
*
".jl"
],
"/"
);
return
filespec
;
println
(
"Writing new"
*
filespec
)
end
;
open
(
filespec
,
"w"
)
do
out
end
;
for
i
in
eachindex
(
progLines
)
print
(
out
,
progLines
[
i
])
end
end
end
include_string
(
Main
,
join
(
progLines
),
name
)
end
# JuliaTikz
end
;
# end module
end
;
# end module
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment