From f80a8573d30d1a73ff472ca9baac181e33d06955 Mon Sep 17 00:00:00 2001 From: Jean-Marie 'Histausse' Mineau Date: Thu, 21 Mar 2024 14:37:03 +0100 Subject: [PATCH] add shorthands for graph --- README.md | 17 ++++++++++++++++- lib.typ | 4 ++++ template/main.typ | 12 ++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 714e14a..c97af55 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,22 @@ digraph mygraph { \``` ``` +`digraphLR`, `digraphTB`, `graphLR` and `graphTB` remove boilerplate code where writing in a hurry: + +``` +\```digraphLR +a -> b; +b -> c; +c -> a; +\``` + +\```graphTB +a -- b; +b -- c; +c -- a; +\``` +``` + ### Todo ``` @@ -47,6 +63,5 @@ Lorem ipsum dolore #todo[sit] amet ## TODO: -- add new raw type with graphviz boillerplate code - biblio - add a list of all todo at the end of the file diff --git a/lib.typ b/lib.typ index 751db1b..2c74bb1 100644 --- a/lib.typ +++ b/lib.typ @@ -2,6 +2,10 @@ #let notes-template(doc) = [ #show raw.where(lang: "dot-render"): it => render-image(it.text) + #show raw.where(lang: "digraphLR"): it => render-image("digraph mygraph { rankdir=\"LR\";" + it.text + "}") + #show raw.where(lang: "digraphTB"): it => render-image("digraph mygraph { rankdir=\"TB\";" + it.text + "}") + #show raw.where(lang: "graphLR"): it => render-image("graph mygraph { rankdir=\"TB\";" + it.text + "}") + #show raw.where(lang: "graphTB"): it => render-image("graph mygraph { rankdir=\"TB\";" + it.text + "}") #doc ] diff --git a/template/main.typ b/template/main.typ index 10476de..ba93643 100644 --- a/template/main.typ +++ b/template/main.typ @@ -10,4 +10,16 @@ digraph mygraph { } ``` +```digraphLR +a -> b; +b -> c; +c -> a; +``` + +```graphTB +a -- b; +b -- c; +c -- a; +``` + Lorem ipsum dolore #todo[sit] amet