About Social Code
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2024-02-14 08:07:44 -0500
committerLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2024-02-14 08:07:44 -0500
commitf102b0d4929084204c4228369c33d89ec8603c54 (patch)
tree6cde044febfa08d438caaf21c245aa4395d41750
parent499e8256adb97496ad6c2fc7070326446c1e9870 (diff)
Add plantuml script
-rw-r--r--html/feed.xml2
-rw-r--r--html/graphics_feed.xml2
-rw-r--r--html/index.html4
-rw-r--r--makefile4
-rw-r--r--tools/pandoc-plantuml.py79
5 files changed, 87 insertions, 4 deletions
diff --git a/html/feed.xml b/html/feed.xml
index 732eff6..451dc01 100644
--- a/html/feed.xml
+++ b/html/feed.xml
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
-<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Fryzek Concepts</title><atom:link href="https://fryzekconcepts.com/feed.xml" rel="self" type="application/rss+xml"/><link>https://fryzekconcepts.com</link><description>Lucas is a developer working on cool things</description><lastBuildDate>Mon, 25 Sep 2023 19:42:54 -0000</lastBuildDate><item><title>Generating Video</title><link>https://fryzekconcepts.com/notes/generating-video.html</link><description>&lt;p&gt;One thing I’m very interested in is computer graphics. This could be
+<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Fryzek Concepts</title><atom:link href="https://fryzekconcepts.com/feed.xml" rel="self" type="application/rss+xml"/><link>https://fryzekconcepts.com</link><description>Lucas is a developer working on cool things</description><lastBuildDate>Wed, 14 Feb 2024 13:05:33 -0000</lastBuildDate><item><title>Generating Video</title><link>https://fryzekconcepts.com/notes/generating-video.html</link><description>&lt;p&gt;One thing I’m very interested in is computer graphics. This could be
complex 3D graphics or simple 2D graphics. The idea of getting a
computer to display visual data fascinates me. One fundamental part of
showing visual data is interfacing with a computer monitor. This can be
diff --git a/html/graphics_feed.xml b/html/graphics_feed.xml
index 1b188ef..95ccca7 100644
--- a/html/graphics_feed.xml
+++ b/html/graphics_feed.xml
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
-<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Fryzek Concepts</title><atom:link href="https://fryzekconcepts.com/feed.xml" rel="self" type="application/rss+xml"/><link>https://fryzekconcepts.com</link><description>Lucas is a developer working on cool things</description><lastBuildDate>Mon, 25 Sep 2023 19:42:55 -0000</lastBuildDate><item><title>2022 Graphics Team Contributions at Igalia</title><link>https://fryzekconcepts.com/notes/2022_igalia_graphics_team.html</link><description>&lt;p&gt;This year I started a new job working with &lt;a
+<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Fryzek Concepts</title><atom:link href="https://fryzekconcepts.com/feed.xml" rel="self" type="application/rss+xml"/><link>https://fryzekconcepts.com</link><description>Lucas is a developer working on cool things</description><lastBuildDate>Wed, 14 Feb 2024 13:05:34 -0000</lastBuildDate><item><title>2022 Graphics Team Contributions at Igalia</title><link>https://fryzekconcepts.com/notes/2022_igalia_graphics_team.html</link><description>&lt;p&gt;This year I started a new job working with &lt;a
href="https://www.igalia.com/technology/graphics"&gt;Igalia’s Graphics
Team&lt;/a&gt;. For those of you who don’t know &lt;a
href="https://www.igalia.com/"&gt;Igalia&lt;/a&gt; they are a &lt;a
diff --git a/html/index.html b/html/index.html
index 4164709..780e3a9 100644
--- a/html/index.html
+++ b/html/index.html
@@ -66,8 +66,8 @@
<div class="note-box">
<img src="/assets/freedreno/glinfo_freedreno_preview.png">
<h2>Journey Through Freedreno</h2>
- <p>Android running FreedrenoAs part of my training at Igalia
- I’ve been attempting to write a new ...</p>
+ <p>Android running FreedrenoAndroid running FreedrenoAs part
+ of my training at Igalia I’ve been to ...</p>
</div>
</a>
<a href="/notes/rasterizing-triangles.html" class="note-link">
diff --git a/makefile b/makefile
index 497382d..f48526e 100644
--- a/makefile
+++ b/makefile
@@ -10,6 +10,8 @@ HTML_DOCS=$(patsubst $(SRC_DIR)/%,$(HTML_DIR)/notes/%,$(SOURCE_DOCS:.md=.html))
SOURCE_FILES=$(patsubst $(SRC_DIR)/%,%,$(SOURCE_DOCS:.md=))
PAGE_FILES=$(patsubst $(PAGE_DIR)/%,$(HTML_DIR)/%,$(PAGE_DOCS:.md=.html))
+export PLANTUML_LIMIT_SIZE=16384
+
$(BUILD_DIR)/%.meta: $(SRC_DIR)/%.md
@mkdir -p $(BUILD_DIR)
pandoc --write=tools/link_gen.lua $< -o $@
@@ -20,6 +22,7 @@ $(HTML_DIR)/notes/%.html: $(BUILD_DIR)/%.meta $(META_DOCS)
@mkdir -p $(HTML_DIR)/notes
pandoc -s --template=./templates/main.html \
--lua-filter=./tools/note.lua \
+ --filter ./tools/pandoc-plantuml.py \
$(patsubst $(BUILD_DIR)/%,$(SRC_DIR)/%,$(<:.meta=.md)) \
--highlight-style=pygments \
-o $@
@@ -31,6 +34,7 @@ $(HTML_DIR)/%.html: $(PAGE_DIR)/%.md
--highlight-style=pygments \
-M main_class="html-main-page" \
-M main_container="main-container-page" \
+ --filter ./tools/pandoc-plantuml.py \
-o $@
$(HTML_DIR)/feed.xml: $(META_DOCS)
diff --git a/tools/pandoc-plantuml.py b/tools/pandoc-plantuml.py
new file mode 100644
index 0000000..2e92fa7
--- /dev/null
+++ b/tools/pandoc-plantuml.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+
+"""
+Pandoc filter to process code blocks with class "plantuml" into
+plant-generated images.
+Needs `plantuml.jar` from http://plantuml.com/.
+"""
+
+import os
+import sys
+import subprocess
+from pathlib import Path
+
+from pandocfilters import toJSONFilter, Para, Image
+from pandocfilters import get_filename4code, get_caption, get_extension, stringify
+
+PLANTUML_BIN = os.environ.get("PLANTUML_BIN", "plantuml")
+
+counter = 0
+
+def rel_mkdir_symlink(src, dest):
+ dest_dir = os.path.dirname(dest)
+ if dest_dir and not os.path.exists(dest_dir):
+ os.makedirs(dest_dir)
+
+ if os.path.exists(dest):
+ os.remove(dest)
+
+ src = os.path.relpath(src, dest_dir)
+ os.symlink(src, dest)
+
+
+def plantuml(key, value, format_, meta):
+ global counter
+ if key == "CodeBlock":
+ [[ident, classes, keyvals], code] = value
+ if "plantuml" in classes:
+ title = stringify(meta.get("title")).replace(" ", "_")
+ caption, typef, keyvals = get_caption(keyvals)
+
+ if meta.get("plantuml-format"):
+ pformat = meta.get("plantuml-format", None)
+ filetype = get_extension(format_, pformat["c"][0]["c"])
+ else:
+ filetype = get_extension(format_, "png", html="svg", latex="png")
+
+ src_folder = f"build/diag/{title}/"
+ src = f"{src_folder}/{counter}.uml"
+ filename = f"{counter}.{filetype}"
+ base_folder = f"assets/diag/{title}"
+ base = f"{base_folder}/{filename}"
+ dest_folder = f"html/{base_folder}"
+ dest = f"{dest_folder}/{filename}"
+
+ Path(src_folder).mkdir(parents=True, exist_ok=True)
+ Path(dest_folder).mkdir(parents=True, exist_ok=True)
+
+ # Generate image only once
+ txt = code.encode(sys.getfilesystemencoding())
+ if not txt.startswith(b"@start"):
+ txt = b"@startuml\n" + txt + b"\n@enduml\n"
+ with open(src, "wb") as f:
+ f.write(txt)
+
+ subprocess.check_call(PLANTUML_BIN.split() + ["-t" + filetype, src,
+ "-o",
+ os.path.abspath(dest_folder)])
+ sys.stderr.write("Created image " + dest + "\n")
+
+ counter += 1
+ return Para([Image([ident, [], keyvals], caption, ["/"+base, typef])])
+
+
+def main():
+ toJSONFilter(plantuml)
+
+
+if __name__ == "__main__":
+ main()