summaryrefslogtreecommitdiff
path: root/macros/luatex/latex/plantuml
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/latex/plantuml')
-rw-r--r--macros/luatex/latex/plantuml/CHANGELOG.md50
-rw-r--r--macros/luatex/latex/plantuml/README.md104
-rw-r--r--macros/luatex/latex/plantuml/example-class-relations--latex.tex19
-rw-r--r--macros/luatex/latex/plantuml/example-class-relations--svg.pngbin0 -> 13997 bytes
-rw-r--r--macros/luatex/latex/plantuml/example-class-relations--svg.tex26
-rw-r--r--macros/luatex/latex/plantuml/example-minimal.pngbin0 -> 4829 bytes
-rw-r--r--macros/luatex/latex/plantuml/example-minimal.tex9
-rw-r--r--macros/luatex/latex/plantuml/plantuml.lua48
-rw-r--r--macros/luatex/latex/plantuml/plantuml.pdfbin0 -> 47135 bytes
-rw-r--r--macros/luatex/latex/plantuml/plantuml.sty101
-rwxr-xr-xmacros/luatex/latex/plantuml/release.sh11
11 files changed, 368 insertions, 0 deletions
diff --git a/macros/luatex/latex/plantuml/CHANGELOG.md b/macros/luatex/latex/plantuml/CHANGELOG.md
new file mode 100644
index 0000000000..5c84bfc5b2
--- /dev/null
+++ b/macros/luatex/latex/plantuml/CHANGELOG.md
@@ -0,0 +1,50 @@
+# Changelog
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](http://keepachangelog.com/)
+and this project adheres to [Semantic Versioning](http://semver.org/).
+
+## [0.2.3] - 2018-06-04
+
+## Added
+
+- Add `release.sh` to CTAN upload-
+
+## Removed
+
+- Removed `\usepackage{aeguill}` as 1) PlantUML seems not to rely on it any more and 2) [it is obsolete and should not be used anymore](https://tex.stackexchange.com/a/5901/9075).
+
+## [0.2.2] - 2018-03-22
+
+## Changed
+
+- Added version number in generated `plantuml.pdf`.
+- Do not strip down `README.md` for CTAN anymore and provide "*.png" for generation of `plantuml.pdf`.
+
+## [0.2.1] - 2018-03-21
+
+### Fixed
+
+- Added short version of `README.md` to CTAN distribution again, because of [CTAN rules](https://mirror.informatik.hs-fulda.de/tex-archive/help/ctan/CTAN-upload-addendum.html#readme).
+
+## [0.2.0] - 2018-03-20
+
+### Changed
+
+- `README.md` is not distributed to CTAN anymore, because `plantuml.pdf` is distributed to follow latex software conventions to name the manual according to the name of the package.
+ `plantuml.pdf` generated out of `README.md`.
+- Removed call to `pdfcrop` is not necessary anymore, because inkscape is called without `-D` for svg convertion.
+
+### Added
+
+- `release.sh` for creating a release.
+
+## 0.1.0 - 2018-03-08
+
+Initial public release
+
+[unreleased]: https://github.com/latextemplates/plantuml/compare/0.2.3...HEAD
+[0.2.3]: https://github.com/latextemplates/plantuml/compare/0.2.2...0.2.3
+[0.2.2]: https://github.com/latextemplates/plantuml/compare/0.2.1...0.2.2
+[0.2.1]: https://github.com/latextemplates/plantuml/compare/0.2.0...0.2.1
+[0.2.0]: https://github.com/latextemplates/plantuml/compare/0.1.0...0.2.0
diff --git a/macros/luatex/latex/plantuml/README.md b/macros/luatex/latex/plantuml/README.md
new file mode 100644
index 0000000000..531ee379f2
--- /dev/null
+++ b/macros/luatex/latex/plantuml/README.md
@@ -0,0 +1,104 @@
+# plantuml
+
+Version 0.2.3
+
+> 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 <https://sourceforge.net/projects/plantuml/files/plantuml.jar/download>.
+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:**
+
+![Minimal example](example-minimal.png)
+
+### Example Class Relations Rendered Using SVG
+
+**LaTeX source:**
+
+```latex
+\documentclass{scrartcl}
+\usepackage{graphics}
+\usepackage{epstopdf}
+\epstopdfDeclareGraphicsRule{.svg}{pdf}{.pdf}{
+ inkscape -z --file=#1 --export-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:**
+
+![Class relations rendered using SVG](example-class-relations--svg.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
+
+The release is built at [CircleCI](http://circleci.com/) using [release.sh](release.sh).
+
+Release prepration:
+
+1. Adapt date and version number in `plantuml.sty`.
+1. Adapt `CHANGELOG.md`.
+1. Set a git tag and push.
+
+## Alternative Solutions
+
+[TikZ-UML](https://perso.ensta-paristech.fr/~kielbasi/tikzuml/) is a very powerful package based in [TikZ](https://www.ctan.org/pkg/pgf).
+More alternative solutions are collected at the [CTAN topic UML](https://www.ctan.org/topic/uml).
+
+## License
+
+`SPDX-License-Identifier: LPPL-1.3c+`
diff --git a/macros/luatex/latex/plantuml/example-class-relations--latex.tex b/macros/luatex/latex/plantuml/example-class-relations--latex.tex
new file mode 100644
index 0000000000..190b2f5668
--- /dev/null
+++ b/macros/luatex/latex/plantuml/example-class-relations--latex.tex
@@ -0,0 +1,19 @@
+\documentclass{scrartcl}
+
+\usepackage{graphics}
+
+\usepackage[output=latex]{plantuml}
+% Have sans serif font at each tikz diagram. Source: https://tex.stackexchange.com/a/4888/9075
+\tikzstyle{every picture}+=[font=\sffamily]
+
+\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/macros/luatex/latex/plantuml/example-class-relations--svg.png b/macros/luatex/latex/plantuml/example-class-relations--svg.png
new file mode 100644
index 0000000000..2461e00812
--- /dev/null
+++ b/macros/luatex/latex/plantuml/example-class-relations--svg.png
Binary files differ
diff --git a/macros/luatex/latex/plantuml/example-class-relations--svg.tex b/macros/luatex/latex/plantuml/example-class-relations--svg.tex
new file mode 100644
index 0000000000..5d7d9b8ed8
--- /dev/null
+++ b/macros/luatex/latex/plantuml/example-class-relations--svg.tex
@@ -0,0 +1,26 @@
+\documentclass{scrartcl}
+
+\usepackage{graphics}
+
+% Enables inclusion of SVG graphics - 1:1 approach
+% This is NOT the approach of https://ctan.org/pkg/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 --file=#1 --export-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}
diff --git a/macros/luatex/latex/plantuml/example-minimal.png b/macros/luatex/latex/plantuml/example-minimal.png
new file mode 100644
index 0000000000..7699a8b185
--- /dev/null
+++ b/macros/luatex/latex/plantuml/example-minimal.png
Binary files differ
diff --git a/macros/luatex/latex/plantuml/example-minimal.tex b/macros/luatex/latex/plantuml/example-minimal.tex
new file mode 100644
index 0000000000..36c0dac014
--- /dev/null
+++ b/macros/luatex/latex/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/macros/luatex/latex/plantuml/plantuml.lua b/macros/luatex/latex/plantuml/plantuml.lua
new file mode 100644
index 0000000000..d94e93b5b4
--- /dev/null
+++ b/macros/luatex/latex/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/macros/luatex/latex/plantuml/plantuml.pdf b/macros/luatex/latex/plantuml/plantuml.pdf
new file mode 100644
index 0000000000..7c9d89e4c3
--- /dev/null
+++ b/macros/luatex/latex/plantuml/plantuml.pdf
Binary files differ
diff --git a/macros/luatex/latex/plantuml/plantuml.sty b/macros/luatex/latex/plantuml/plantuml.sty
new file mode 100644
index 0000000000..d6777ed44e
--- /dev/null
+++ b/macros/luatex/latex/plantuml/plantuml.sty
@@ -0,0 +1,101 @@
+%% Copyright (C) 2018 Oliver Kopp, https://github.com/koppor
+%%
+%% SPDX-License-Identifier: LPPL-1.3c+
+\NeedsTeXFormat{LaTeX2e}\relax
+\ProvidesPackage{plantuml}
+ [2018/03/22 v0.2.2
+ Embed PlantUML diagrams in latex documents.]
+
+% Required by PlantUML LaTeX output
+\RequirePackage{tikz}
+
+% 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
+
+\ExplSyntaxOn
+\let\PlantUmlMode\l_plantuml_mode
+\ExplSyntaxOff
+
+\newcounter{PlantUmlFigureNumber}
+
+\ifluatex
+ \RequirePackage{luacode}
+\else
+ \RequirePackage[usefamily=bash]{pythontex}
+\fi
+
+\makeatletter
+\ifcase\pdf@shellescape
+ \message{No shell escape. PlantUML cannot be called. Start pdflatex/lualatex with -shell-escape.}
+ \newenvironment{plantuml}{%
+ No shell escape. PlantUML cannot be called. Start pdflatex/lualatex with -shell-escape.
+ }{}
+\or
+ \ifluatex
+ \directlua{
+ local plantUmlJar = os.getenv("PLANTUML_JAR")
+ if not plantUmlJar then
+ texio.write_nl("Environment variable PLANTUML_JAR not set.")
+ end
+ }
+ \fi
+ \NewDocumentEnvironment{plantuml}{}{%
+ \VerbatimOut{\jobname-plantuml.txt}}
+ {%
+ \endVerbatimOut
+ \ifluatex
+ \directlua{
+ local jobname=\luastring{\jobname}
+ local plantUmlMode=\luastring{\PlantUmlMode}
+ require("plantuml.lua")
+ convertPlantUmlToTikz(jobname, plantUmlMode)
+ }
+ \else
+ \stepcounter{PlantUmlFigureNumber}
+ %TODO: Execute pyhton here
+ \typeout{*** plantuml only works with lualatex ***}
+ \fi
+ \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 pdflatex/lualatex with -shell-escape.}
+ \newenvironment{plantuml}{%
+ Restricted shell escape. PlantUML cannot be called. Start pdflatex/lualatex with -shell-escape.
+ }{}
+\fi
+\makeatother
+
diff --git a/macros/luatex/latex/plantuml/release.sh b/macros/luatex/latex/plantuml/release.sh
new file mode 100755
index 0000000000..bf8bbd5444
--- /dev/null
+++ b/macros/luatex/latex/plantuml/release.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+TAG=`git describe --abbrev=0 --tags`
+
+# remove shields.io badge
+sed -i "s/# plantuml.*/# plantuml\n\nVersion $TAG/" README.md
+
+# generate plantuml.pdf based on README.md based on pandoc 2.x
+pandoc README.md --pdf-engine=lualatex -o plantuml.pdf
+
+# Prepare for CTAN
+ctanify --notds plantuml.sty plantuml.lua plantuml.pdf README.md CHANGELOG.md release.sh "example-*.tex" "example-*.png"