texlive[46892] Master: plantuml (8mar18)

commits+karl at tug.org commits+karl at tug.org
Thu Mar 8 23:56:58 CET 2018


Revision: 46892
          http://tug.org/svn/texlive?view=revision&revision=46892
Author:   karl
Date:     2018-03-08 23:56:58 +0100 (Thu, 08 Mar 2018)
Log Message:
-----------
plantuml (8mar18)

Modified Paths:
--------------
    trunk/Master/tlpkg/bin/tlpkg-ctan-check
    trunk/Master/tlpkg/libexec/ctan2tds
    trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/lualatex/plantuml/
    trunk/Master/texmf-dist/doc/lualatex/plantuml/README.md
    trunk/Master/texmf-dist/doc/lualatex/plantuml/example-class-relations.png
    trunk/Master/texmf-dist/doc/lualatex/plantuml/example-class-relations.tex
    trunk/Master/texmf-dist/doc/lualatex/plantuml/example-minimal.png
    trunk/Master/texmf-dist/doc/lualatex/plantuml/example-minimal.tex
    trunk/Master/texmf-dist/tex/lualatex/plantuml/
    trunk/Master/texmf-dist/tex/lualatex/plantuml/plantuml.lua
    trunk/Master/texmf-dist/tex/lualatex/plantuml/plantuml.sty
    trunk/Master/tlpkg/tlpsrc/plantuml.tlpsrc

Added: trunk/Master/texmf-dist/doc/lualatex/plantuml/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/plantuml/README.md	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/lualatex/plantuml/README.md	2018-03-08 22:56:58 UTC (rev 46892)
@@ -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 <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:**
+
+![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}
+ at startuml
+class Car
+
+Driver - Car : drives >
+Car *- Wheel : have 4 >
+Car -- Person : < owns
+ at 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+`


Property changes on: trunk/Master/texmf-dist/doc/lualatex/plantuml/README.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/lualatex/plantuml/example-class-relations.png
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/lualatex/plantuml/example-class-relations.png
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/plantuml/example-class-relations.png	2018-03-08 22:54:53 UTC (rev 46891)
+++ trunk/Master/texmf-dist/doc/lualatex/plantuml/example-class-relations.png	2018-03-08 22:56:58 UTC (rev 46892)

Property changes on: trunk/Master/texmf-dist/doc/lualatex/plantuml/example-class-relations.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/lualatex/plantuml/example-class-relations.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/plantuml/example-class-relations.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/lualatex/plantuml/example-class-relations.tex	2018-03-08 22:56:58 UTC (rev 46892)
@@ -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}
+ at startuml
+class Car
+
+Driver - Car : drives >
+Car *- Wheel : have 4 >
+Car -- Person : < owns
+ at enduml
+\end{plantuml}
+\end{document}


Property changes on: trunk/Master/texmf-dist/doc/lualatex/plantuml/example-class-relations.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/lualatex/plantuml/example-minimal.png
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/lualatex/plantuml/example-minimal.png
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/plantuml/example-minimal.png	2018-03-08 22:54:53 UTC (rev 46891)
+++ trunk/Master/texmf-dist/doc/lualatex/plantuml/example-minimal.png	2018-03-08 22:56:58 UTC (rev 46892)

Property changes on: trunk/Master/texmf-dist/doc/lualatex/plantuml/example-minimal.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/lualatex/plantuml/example-minimal.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/plantuml/example-minimal.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/lualatex/plantuml/example-minimal.tex	2018-03-08 22:56:58 UTC (rev 46892)
@@ -0,0 +1,9 @@
+\documentclass{scrartcl}
+\usepackage{plantuml}
+\begin{document}
+\begin{plantuml}
+ at startuml
+Alice -> Bob: test
+ at enduml
+\end{plantuml}
+\end{document}


Property changes on: trunk/Master/texmf-dist/doc/lualatex/plantuml/example-minimal.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/lualatex/plantuml/plantuml.lua
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/plantuml/plantuml.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/lualatex/plantuml/plantuml.lua	2018-03-08 22:56:58 UTC (rev 46892)
@@ -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


Property changes on: trunk/Master/texmf-dist/tex/lualatex/plantuml/plantuml.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/lualatex/plantuml/plantuml.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/plantuml/plantuml.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/lualatex/plantuml/plantuml.sty	2018-03-08 22:56:58 UTC (rev 46892)
@@ -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 at nat@width>#1 #1\else\Gin at nat@width\fi}
+\makeatother
+
+\ifluatex
+  \ExplSyntaxOn
+  \let\PlantUmlMode\l_plantuml_mode
+  \ExplSyntaxOff
+  \RequirePackage{luacode}
+  \makeatletter
+  \ifcase\pdf at 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
+


Property changes on: trunk/Master/texmf-dist/tex/lualatex/plantuml/plantuml.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check	2018-03-08 22:54:53 UTC (rev 46891)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check	2018-03-08 22:56:58 UTC (rev 46892)
@@ -495,7 +495,7 @@
     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

Modified: trunk/Master/tlpkg/libexec/ctan2tds
===================================================================
--- trunk/Master/tlpkg/libexec/ctan2tds	2018-03-08 22:54:53 UTC (rev 46891)
+++ trunk/Master/tlpkg/libexec/ctan2tds	2018-03-08 22:56:58 UTC (rev 46892)
@@ -1786,6 +1786,7 @@
  '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',

Modified: trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc	2018-03-08 22:54:53 UTC (rev 46891)
+++ trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc	2018-03-08 22:56:58 UTC (rev 46892)
@@ -34,6 +34,7 @@
 depend nodetree
 depend odsfile
 depend placeat
+depend plantuml
 depend selnolig
 depend spelling
 depend typewriter

Added: trunk/Master/tlpkg/tlpsrc/plantuml.tlpsrc
===================================================================


More information about the tex-live-commits mailing list