From da48a65f7e454f173c138f38ac4cc5661f4c1cea Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 8 Mar 2018 22:56:58 +0000 Subject: plantuml (8mar18) git-svn-id: svn://tug.org/texlive/trunk@46892 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/lualatex/plantuml/README.md | 94 +++++++++++++++++++++ .../lualatex/plantuml/example-class-relations.png | Bin 0 -> 13997 bytes .../lualatex/plantuml/example-class-relations.tex | 29 +++++++ .../doc/lualatex/plantuml/example-minimal.png | Bin 0 -> 4829 bytes .../doc/lualatex/plantuml/example-minimal.tex | 9 ++ .../texmf-dist/tex/lualatex/plantuml/plantuml.lua | 48 +++++++++++ .../texmf-dist/tex/lualatex/plantuml/plantuml.sty | 90 ++++++++++++++++++++ Master/tlpkg/bin/tlpkg-ctan-check | 2 +- Master/tlpkg/libexec/ctan2tds | 1 + Master/tlpkg/tlpsrc/collection-luatex.tlpsrc | 1 + Master/tlpkg/tlpsrc/plantuml.tlpsrc | 0 11 files changed, 273 insertions(+), 1 deletion(-) create mode 100644 Master/texmf-dist/doc/lualatex/plantuml/README.md create mode 100644 Master/texmf-dist/doc/lualatex/plantuml/example-class-relations.png create mode 100644 Master/texmf-dist/doc/lualatex/plantuml/example-class-relations.tex create mode 100644 Master/texmf-dist/doc/lualatex/plantuml/example-minimal.png create mode 100644 Master/texmf-dist/doc/lualatex/plantuml/example-minimal.tex create mode 100644 Master/texmf-dist/tex/lualatex/plantuml/plantuml.lua create mode 100644 Master/texmf-dist/tex/lualatex/plantuml/plantuml.sty create mode 100644 Master/tlpkg/tlpsrc/plantuml.tlpsrc diff --git a/Master/texmf-dist/doc/lualatex/plantuml/README.md b/Master/texmf-dist/doc/lualatex/plantuml/README.md new file mode 100644 index 00000000000..195ec4d06be --- /dev/null +++ b/Master/texmf-dist/doc/lualatex/plantuml/README.md @@ -0,0 +1,94 @@ +# plantuml + +> A LuaLaTeX package for PlantUML in LaTeX + +[PlantUML](http://plantuml.com/) is a program which transforms text into UML diagrams. +This package allows for embedding PlantUML diagrams using the PlantUML source. + +Currently, this project runs with [lualatex](http://www.luatex.org/) only. +Check [issue #1](https://github.com/latextemplates/plantuml/issues/1) for the current state of affairs for support pdflatex. + +## Preconditions + +1. Environment variable `PLANTUML_JAR` set to the location of `plantuml.jar`. + You get it from . +2. Enviroment variable `GRAPHVIZ_DOT` set to the location of `dot.exe`. + Example: `C:\Program Files (x86)\Graphviz2.38\bin\dot.exe`. + You can install graphviz using `choco install graphviz`. +3. lualatex available with command line parameter `-shell-escape` included. +4. In case you want to have the images as PDFs (and not using TikZ or PNG), ensure that `inkscape.exe` and `pdfcrop` are in your path. + You can get inkscape using `choco install inkscape`. + `pdfcrop` should be part of your latex distribution. + +## Examples + +### Minimal Example + +**LaTeX source:** + +```latex +\documentclass{scrartcl} +\usepackage{plantuml} +\begin{document} +\begin{plantuml} + @startuml + Alice -> Bob: test + @enduml +\end{plantuml} +\end{document} +``` + +**Compilation:** `lualatex -shell-escape example-minimal` + +**Result:** + +![example minimal](example-minimal.png) + +### Example Class Relations Rendered using SVG + +**LaTeX source:** + +```latex +\documentclass{scrartcl} +\usepackage{graphics} +\usepackage{epstopdf} +\epstopdfDeclareGraphicsRule{.svg}{pdf}{.pdf}{% + inkscape -z -D --file=#1 --export-pdf=\jobname-plantuml-svg.pdf && + pdfcrop \jobname-plantuml-svg.pdf \OutputFile +} +\usepackage[output=svg]{plantuml} +\begin{document} +\begin{plantuml} +@startuml +class Car + +Driver - Car : drives > +Car *- Wheel : have 4 > +Car -- Person : < owns +@enduml +\end{plantuml} +\end{document} +``` + +**Compilation:** `lualatex -shell-escape example-class-relations` + +**Result:** + +![example minimal](example-class-relations.png) + +## Installation + +Your latex distribution should take care. + +For manual installation, copy `plantuml.*` to your local texmf folder in the subdirectoy `tex/latex/plantuml`. +See [the discussion at tex.sx](https://tex.stackexchange.com/q/27982/9075) for the concrete location of the folder on your system. + +## Development + +### Releasing + +- `ctanify --notds plantuml.sty plantuml.lua README.md "*.png" "example-*.tex"` + +## License + +`SPDX-License-Identifier: LPPL-1.3c+` diff --git a/Master/texmf-dist/doc/lualatex/plantuml/example-class-relations.png b/Master/texmf-dist/doc/lualatex/plantuml/example-class-relations.png new file mode 100644 index 00000000000..2461e00812f Binary files /dev/null and b/Master/texmf-dist/doc/lualatex/plantuml/example-class-relations.png differ diff --git a/Master/texmf-dist/doc/lualatex/plantuml/example-class-relations.tex b/Master/texmf-dist/doc/lualatex/plantuml/example-class-relations.tex new file mode 100644 index 00000000000..e5c131104db --- /dev/null +++ b/Master/texmf-dist/doc/lualatex/plantuml/example-class-relations.tex @@ -0,0 +1,29 @@ +\documentclass{scrartcl} + +\usepackage{graphics} + +% Enables inclusion of SVG graphics - 1:1 approach +% This is NOT the approach of http://www.ctan.org/tex-archive/info/svg-inkscape, +% which allows text in SVG to be typeset using LaTeX +% We just include the SVG as is +\usepackage{epstopdf} +\epstopdfDeclareGraphicsRule{.svg}{pdf}{.pdf}{% + inkscape -z -D --file=#1 --export-pdf=\jobname-plantuml-svg.pdf && + %due to https://bugs.launchpad.net/inkscape/+bug/1754167 we need to use pdfcrop + pdfcrop \jobname-plantuml-svg.pdf \OutputFile +} + +\usepackage[output=svg]{plantuml} +%\usepackage[output=latex]{plantuml} + +\begin{document} +\begin{plantuml} +@startuml +class Car + +Driver - Car : drives > +Car *- Wheel : have 4 > +Car -- Person : < owns +@enduml +\end{plantuml} +\end{document} diff --git a/Master/texmf-dist/doc/lualatex/plantuml/example-minimal.png b/Master/texmf-dist/doc/lualatex/plantuml/example-minimal.png new file mode 100644 index 00000000000..7699a8b1850 Binary files /dev/null and b/Master/texmf-dist/doc/lualatex/plantuml/example-minimal.png differ diff --git a/Master/texmf-dist/doc/lualatex/plantuml/example-minimal.tex b/Master/texmf-dist/doc/lualatex/plantuml/example-minimal.tex new file mode 100644 index 00000000000..36c0dac0143 --- /dev/null +++ b/Master/texmf-dist/doc/lualatex/plantuml/example-minimal.tex @@ -0,0 +1,9 @@ +\documentclass{scrartcl} +\usepackage{plantuml} +\begin{document} +\begin{plantuml} +@startuml +Alice -> Bob: test +@enduml +\end{plantuml} +\end{document} diff --git a/Master/texmf-dist/tex/lualatex/plantuml/plantuml.lua b/Master/texmf-dist/tex/lualatex/plantuml/plantuml.lua new file mode 100644 index 00000000000..d94e93b5b44 --- /dev/null +++ b/Master/texmf-dist/tex/lualatex/plantuml/plantuml.lua @@ -0,0 +1,48 @@ +-- SPDX-License-Identifier: LPPL-1.3c+ + +require "lfs" + +-- @param mode directly passed to PlantUML. Recommended: png, svg, pdf (requires Apache Batik to convert svg to pdf) +function convertPlantUmlToTikz(jobname, mode) + local plantUmlSourceFilename = jobname .. "-plantuml.txt" + local plantUmlTargetFilename = jobname .. "-plantuml." .. mode + + -- delete generated file to ensure they are really recreated + os.remove(plantUmlTargetFilename) + + if not (lfs.attributes(plantUmlSourceFilename)) then + texio.write_nl("Source " .. plantUmlSourceFilename .. " does not exist.") + return + end + + local plantUmlJar = os.getenv("PLANTUML_JAR") + if not plantUmlJar then + texio.write_nl("Environment variable PLANTUML_JAR not set.") + return + end + + texio.write("Executing PlantUML... ") + local cmd = "java -jar " .. plantUmlJar .. " -t" + if (mode == "latex") then + cmd = cmd .. "latex:nopreamble" + else + cmd = cmd .. mode + end + cmd = cmd .. " " .. plantUmlSourceFilename + texio.write_nl(cmd) + local handle,error = io.popen(cmd) + if not handle then + texio.write_nl("Error during execution of PlantUML.") + texio.write_nl(error) + return + end + io.close(handle) + + if not (lfs.attributes(plantUmlTargetFilename)) then + texio.write_nl("PlantUML did not generate anything.") + handle = io.open(plantUmlTargetFilename, "w") + handle:write("Error during latex code generation") + io.close(handle) + return + end +end diff --git a/Master/texmf-dist/tex/lualatex/plantuml/plantuml.sty b/Master/texmf-dist/tex/lualatex/plantuml/plantuml.sty new file mode 100644 index 00000000000..3f16671ea06 --- /dev/null +++ b/Master/texmf-dist/tex/lualatex/plantuml/plantuml.sty @@ -0,0 +1,90 @@ +%% Copyright (C) 2018 Oliver Kopp, https://github.com/koppor +%% +%% SPDX-License-Identifier: LPPL-1.3c+ +\NeedsTeXFormat{LaTeX2e}\relax +\ProvidesPackage{plantuml} + [2018/03/08 v0.1.0 + Embed PlantUML diagrams in latex documents.] + +% Required by PlantUML LaTeX output +\RequirePackage{tikz} +\RequirePackage{aeguill} + +% Enable checking for active -shell-escape +% Source: https://tex.stackexchange.com/a/88620/9075 +\RequirePackage{pdftexcmds} + +% Prepare writing contents of a self-defined environment to a file +% Source: https://tex.stackexchange.com/a/130298/9075 +\RequirePackage{fancyvrb} + +\RequirePackage{l3keys2e} +\RequirePackage{xparse} + +\RequirePackage{ifthen} + +\RequirePackage{adjustbox} + +\ExplSyntaxOn +\keys_define:nn { plantuml } { + output .choices:nn = { + {latex, png, svg} + { \tl_gset:NV \l_plantuml_mode \l_keys_choice_tl } + }, + output .initial:n = latex +} +\ProcessKeysOptions { plantuml } +\ExplSyntaxOff + +%hint from https://tex.stackexchange.com/a/86355/9075 +\makeatletter +\def\maxwidth#1{\ifdim\Gin@nat@width>#1 #1\else\Gin@nat@width\fi} +\makeatother + +\ifluatex + \ExplSyntaxOn + \let\PlantUmlMode\l_plantuml_mode + \ExplSyntaxOff + \RequirePackage{luacode} + \makeatletter + \ifcase\pdf@shellescape + \message{No shell escape. PlantUML cannot be called. Start lualatex with -shell-escape.} + \newenvironment{plantuml}{% + No shell escape. PlantUML cannot be called. Start lualatex with -shell-escape. + }{} + \or + \directlua{ + local plantUmlJar = os.getenv("PLANTUML_JAR") + if not plantUmlJar then + texio.write_nl("Environment variable PLANTUML_JAR not set.") + end + } + \NewDocumentEnvironment{plantuml}{}{% + \VerbatimOut{\jobname-plantuml.txt}} + {% + \endVerbatimOut + \directlua{ + local jobname=\luastring{\jobname} + local plantUmlMode=\luastring{\PlantUmlMode} + require("plantuml.lua") + convertPlantUmlToTikz(jobname, plantUmlMode) + } + \ifthenelse{\equal{\PlantUmlMode}{latex}}{ + \begin{adjustbox}{max width=\linewidth} + \input{\jobname-plantuml.latex} + \end{adjustbox} + }{ + \includegraphics[width=\maxwidth{\textwidth}]{\jobname-plantuml.\PlantUmlMode} + } + } + \or + \message{Restricted shell escape. PlantUML cannot be called. Start lualatex with -shell-escape.} + \newenvironment{plantuml}{% + Restricted shell escape. PlantUML cannot be called. Start lualatex with -shell-escape. + }{} + \fi + \makeatother +\else + \typeout{*** plantuml only works with lualatex ***} +\fi + diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index 896bbc34021..1a92deb0439 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -495,7 +495,7 @@ my @TLP_working = qw( pictex pictex2 pictexsum piechartmp piff pigpen pinlabel pitex pittetd pixelart pkfix pkfix-helper pkgloader pkuthss pl placeat placeins placeins-plain - plain-doc plainpkg plari plantslabels plates + plain-doc plainpkg plari plantslabels plantuml plates platex platex-tools platexcheat play playfair plex plex-otf plipsum plnfss plstmary plweb pm-isomath pmgraph pmx pmxchords pnas2009 poemscol poetry poetrytex polexpr polski poltawski diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds index c4374f28ee5..02ef1a09722 100755 --- a/Master/tlpkg/libexec/ctan2tds +++ b/Master/tlpkg/libexec/ctan2tds @@ -1786,6 +1786,7 @@ $standardtex 'pkgloader', '^[^t].*\.sty', # not .cls, not test*.sty 'placeins-plain', 'placeins.tex', 'plain', '\.tex', + 'plantuml',, '\.lua|' . $standardtex, 'plgraph', '\.tex', 'plipsum', 'plipsum.tex', 'plnfss', '\.tex|\.pfd', diff --git a/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc b/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc index 70a08d28eb4..8ee68eb2ed9 100644 --- a/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc @@ -34,6 +34,7 @@ depend luaxml depend nodetree depend odsfile depend placeat +depend plantuml depend selnolig depend spelling depend typewriter diff --git a/Master/tlpkg/tlpsrc/plantuml.tlpsrc b/Master/tlpkg/tlpsrc/plantuml.tlpsrc new file mode 100644 index 00000000000..e69de29bb2d -- cgit v1.2.3