Skip to content

Instantly share code, notes, and snippets.

@neumantm
Last active August 24, 2023 14:26
Show Gist options
  • Save neumantm/bca0e942859f73db59cd273e5e13f5a3 to your computer and use it in GitHub Desktop.
Save neumantm/bca0e942859f73db59cd273e5e13f5a3 to your computer and use it in GitHub Desktop.
Build Markdown with PlantUml snippets
all: editor.pdf language.pdf
BUILD_LANGUAGE_MD:=.build_language_md
IMG_EXTENSIOM:=svg
editor.pdf: editor.md
pandoc -f gfm -i $< -o $@
language.pdf: ${BUILD_LANGUAGE_MD}/language.md ${BUILD_LANGUAGE_MD}/imgs/
pandoc -f gfm -i $< -o $@
${BUILD_LANGUAGE_MD}/language.md: ${BUILD_LANGUAGE_MD} language.md
cat language.md | perl -p0e 's/```plantuml\n\@startuml (.*)\n(.*|\n)*?\@enduml\n```/![$$1](${BUILD_LANGUAGE_MD}\/imgs\/$$1.${IMG_EXTENSIOM})/g' > ${BUILD_LANGUAGE_MD}/language.md
${BUILD_LANGUAGE_MD}/imgs/: ${BUILD_LANGUAGE_MD} language.md
mkdir -p ${BUILD_LANGUAGE_MD}/imgs/
docker run -u $$(id -u):$$(id -g) -v $$(pwd):/src --rm plantuml/plantuml -t${IMG_EXTENSIOM} -o /src/${BUILD_LANGUAGE_MD}/imgs/ /src/language.md
${BUILD_LANGUAGE_MD}:
mkdir -p ${BUILD_LANGUAGE_MD}
.PHONY: clean
clean:
rm -f *.pdf
rm -rf ${BUILD_LANGUAGE_MD}
@neumantm
Copy link
Author

editor.md is a file without any plantuml and language.md is one with embedded plantuml.
The plantuml is embedded in a way, that the vscode extension PlantUML automatically renders them in the preview:

# Language

This is some text, bla bla bla.

```plantuml
@startuml SomeTitle
class Test {
    +name: String
    +version: String
    +description: String
}
@enduml
```

Some more text

## A header

```plantuml
@startuml someOtherTitle
class Test2ab {
    +name2: String
    +version2: String
    +description2: String
}
@enduml
```

foo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment