-
Notifications
You must be signed in to change notification settings - Fork 0
/
marmermaidtex.sty
74 lines (62 loc) · 1.98 KB
/
marmermaidtex.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% (c) Markus Pabst 2022
%%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN archives
%% in directory macros/latex/base/lppl.txt.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% !Note: You have install mermaid.cli --> http//:github.com/mermaid-js/mermaid-cli#Install-globally
%% !Note: You have add to pdflatex --shell-escape command
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{marmermaidtex}
[2022-01-28 v0.03 LaTeX package for include mermaid graphics in latex]
\RequirePackage{
ifthen,
xkeyval,
silence,
iftex,
ifpdf,
graphicx
}
\newboolean{noOverwrite}
\setboolean{noOverwrite}{false}
\newboolean{noWarningOverwrite}
\setboolean{noWarningOverwrite}{false}
\DeclareOptionX{noOverwrite}{
\setboolean{noOverwrite}{true}
}
\DeclareOptionX{noWarningOverwrite}{
\setboolean{noWarningOverwrite}{true}
}
\ProcessOptionsX
\ifthenelse{\NOT\boolean{noOverwrite} \AND \boolean{noWarningOverwrite}}{
\PackageWarning{marmermaidtex}{All warnings for overwrite files a switch off now.}{}
\WarningFilter{latex}{Writing or overwriting file}
}
\newboolean{correctTool}
\setboolean{correctTool}{false}
\ifXeTeX
\setboolean{correctTool}{true}
\fi
\ifpdf
\setboolean{correctTool}{true}
\fi
\ifthenelse{\boolean{correctTool}}{}{\PackageError{marmermaidtex}{You aren't using pdflatex, Xetex, Luatex}{}}
\newenvironment{marmermaidtex}[2][]{
\def\@graphicsopts{#1}
\def\tempFilenameMermaidPdf{#2}
\ifthenelse{\boolean{noOverwrite}}{
\csname filecontents*\endcsname[]{\tempFilenameMermaidPdf.tmp}
}{
\csname filecontents*\endcsname[overwrite]{\tempFilenameMermaidPdf.tmp}
}
}
{
\csname endfilecontents*\endcsname
\immediate\write18{mmdc -i \tempFilenameMermaidPdf.tmp -f -q -o \tempFilenameMermaidPdf}
\expandafter\includegraphics\expandafter[\@graphicsopts]{\tempFilenameMermaidPdf}
}
\endinput
%%
%% End of file `marmermaidtex.sty'.