Commit b5716c65 authored by Henrik Tramberend's avatar Henrik Tramberend
Browse files

Add embedded PlantUML rendering

parent dc340f96
......@@ -258,14 +258,23 @@ run = do
need [src]
command [] "sass" [src, out]
--
"**/*.plantuml.svg" %> \out -> do
let src = dropExtension out
need [src]
putNormal $ "# plantuml (for " <> out <> ")"
plantuml [src]
liftIO $ Dir.renameFile (src -<.> "svg") out
--
"**/*.dot.svg" %> \out -> do
let src = dropExtension out
need [src]
putNormal $ "# dot (for " <> out <> ")"
dot ["-o" ++ out, src]
--
"**/*.gnuplot.svg" %> \out -> do
let src = dropExtension out
need [src]
putNormal $ "# gnuplot (for " <> out <> ")"
gnuplot ["-e", "\"set output '" ++ out ++ "'\"", src]
--
"**/*-recording.mp4" %> \out -> do
......
......@@ -98,7 +98,7 @@ transformImages images caption = do
H.div ! A.class_ "decker image-row" $ toHtml $ map toHtml imageRow
H.figcaption captionHtml
language cls = find (`elem` ["dot", "gnuplot", "tex"]) cls
language cls = find (`elem` ["plantuml", "dot", "gnuplot", "tex"]) cls
-- TODO this is incomplete
-- - captions are just swallowed but never rendered.
......@@ -107,6 +107,8 @@ transformCodeBlock :: Block -> [Inline] -> Filter Block
transformCodeBlock code@(CodeBlock attr@(_, classes, _) text) caption =
handle (blockError code) $
if
| all (`elem` classes) ["plantuml", "render"] ->
runAttr attr (transform "plantuml") >>= renderHtml
| all (`elem` classes) ["dot", "render"] ->
runAttr attr (transform "dot") >>= renderHtml
| all (`elem` classes) ["gnuplot", "render"] ->
......
......@@ -61,7 +61,7 @@ svgExt = ["svg"]
yamlExt = ["yaml", "yml"]
renderExt = ["dot", "gnuplot", "tex"]
renderExt = ["dot", "gnuplot", "tex", "plantuml"]
javascriptExt = ["js"]
......
......@@ -5,6 +5,7 @@ module Text.Decker.Internal.External
( ssh,
rsync,
dot,
plantuml,
gnuplot,
pdflatex,
pdf2svg,
......@@ -63,6 +64,14 @@ programs =
["-V"]
(helpText "Graphviz (http://www.graphviz.org)")
),
( "plantuml",
ExternalProgram
-- []
"plantuml"
["-tsvg"]
["--version"]
(helpText "Plantuml (https://plantuml.com)")
),
( "gnuplot",
ExternalProgram
-- []
......@@ -100,6 +109,9 @@ rsync = makeProgram "rsync"
dot :: Program
dot = makeProgram "dot"
plantuml :: Program
plantuml = makeProgram "plantuml"
gnuplot :: Program
gnuplot = makeProgram "gnuplot"
......
@startuml
skinparam shadowing false
skinparam monochrome true
Alice -> Bob: test
@enduml
\ No newline at end of file
......@@ -12,13 +12,39 @@ Code blocks can be rendered as SVG images
- Gnuplot
- Tikz
------
------------------------------------------------------------------------
# Embedded PlantUML Code (SVG) {.columns}
## PlantUML {.left}
```` {.markdown}
``` {.plantuml .render}
@startuml
skinparam shadowing false
skinparam monochrome true
Alice -> Bob: test
@enduml
```
````
## SVG {.right}
``` {.plantuml .render width="100%"}
@startuml
skinparam shadowing false
skinparam monochrome true
Alice -> Bob: test
@enduml
```
------------------------------------------------------------------------
# Embedded Graphviz Code (SVG) {layout="columns"}
## Highlighted {.left}
```` {.dot}
```` {.markdown}
``` {.dot .render width="80%"}
digraph {
node [style = filled]
......@@ -48,7 +74,7 @@ digraph {
}
```
------
------------------------------------------------------------------------
# Embedded Gnuplot (SVG) {layout="columns"}
......@@ -82,7 +108,21 @@ DEBUG_TERM_VTIC = 118
splot 1 / (x*x + y*y + 0.5)
```
------
------------------------------------------------------------------------
# PlantUML Files as Images {layout="columns"}
## Image Tag {.left}
``` {.markdown}
![](alice-bob.plantuml){.render}
```
## Rendered and included {.right}
![](alice-bob.plantuml){.plantuml .render}
------------------------------------------------------------------------
# Dot Files as Images {layout="columns"}
......@@ -96,7 +136,7 @@ splot 1 / (x*x + y*y + 0.5)
![](graph.dot){.dot .render}
------
------------------------------------------------------------------------
# Tikz Files as Images {layout="columns"}
......@@ -110,7 +150,7 @@ splot 1 / (x*x + y*y + 0.5)
![](tikz.tex){.tex .render}
------
------------------------------------------------------------------------
# Tikz Embedded
......@@ -173,4 +213,3 @@ splot 1 / (x*x + y*y + 0.5)
\end{tikzpicture}
\end{document}
```
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment