{"id":443,"date":"2019-09-21T17:16:27","date_gmt":"2019-09-21T15:16:27","guid":{"rendered":"https:\/\/www.nikostotz.de\/blog\/?p=443"},"modified":"2019-09-21T17:16:27","modified_gmt":"2019-09-21T15:16:27","slug":"how-to-render-a-hierarchical-tree-in-asciidoctor","status":"publish","type":"post","link":"https:\/\/www.nikostotz.de\/blog\/how-to-render-a-hierarchical-tree-in-asciidoctor\/","title":{"rendered":"How to Render a (Hierarchical) Tree in Asciidoctor"},"content":{"rendered":"\n<p>Showing a hierarchical tree, like a file system directory tree, in Asciidoctor is surprisingly hard. We use PlantUML to render the tree on all common platforms.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"253\" height=\"228\" src=\"https:\/\/www.nikostotz.de\/blog\/wp-content\/uploads\/2019\/09\/tree-in-asciidoctor.png\" alt=\"Example of rendered hierarchical tree\" class=\"wp-image-444\"\/><\/figure>\n\n\n\n<p>This tree is rendered from the following code:<\/p>\n\n\n\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/><\/div><\/td><td><div class=\"text codecolorer\">[plantuml, format=svg, opts=&quot;inline&quot;]<br \/>\n----<br \/>\nskinparam Legend {<br \/>\n&nbsp; &nbsp; BackgroundColor transparent<br \/>\n&nbsp; &nbsp; BorderColor transparent<br \/>\n&nbsp; &nbsp; FontName &quot;Noto Serif&quot;, &quot;DejaVu Serif&quot;, serif<br \/>\n&nbsp; &nbsp; FontSize 17<br \/>\n}<br \/>\nlegend<br \/>\nRoot<br \/>\n|_ Element 1<br \/>\n&nbsp; |_ Element 1.1<br \/>\n&nbsp; |_ Element 1.2<br \/>\n|_ Element 2<br \/>\n&nbsp; |_ Element 2.1<br \/>\nend legend<br \/>\n----<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n\n\n\n\n<p>It works on all Asciidoctor implementations that support <tt>asciidoctor-diagram<\/tt> and renders well in both HTML and PDF. Readers can select the text (i.e. it&#8217;s not an image), and we don&#8217;t need to ship additional files.<\/p>\n\n\n\n<p>We might want to externalize the boilerplate:<\/p>\n\n\n\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/><\/div><\/td><td><div class=\"text codecolorer\">[plantuml, format=svg, opts=&quot;inline&quot;]<br \/>\n----<br \/>\n!include asciidoctor-style.iuml<br \/>\nlegend<br \/>\nRoot<br \/>\n|_ Element 1<br \/>\n&nbsp; |_ Element 1.1<br \/>\n&nbsp; |_ Element 1.2<br \/>\n|_ Element 2<br \/>\n&nbsp; |_ Element 2.1<br \/>\nend legend<br \/>\n----<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n\n\n\n\n<i>asciidoctor-style.iuml<\/i>\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/><\/div><\/td><td><div class=\"text codecolorer\">skinparam Legend {<br \/>\n&nbsp; &nbsp; BackgroundColor transparent<br \/>\n&nbsp; &nbsp; BorderColor transparent<br \/>\n&nbsp; &nbsp; FontName &quot;Noto Serif&quot;, &quot;DejaVu Serif&quot;, serif<br \/>\n&nbsp; &nbsp; FontSize 17<br \/>\n}<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n\n\n\n\n<p>Thanks to <a href=\"https:\/\/forum.plantuml.net\/10200\/dont-require-dot-for-shapeless-diagrams-and-svg-output\">PlantUML&#8217;s impressive reaction time<\/a>, we soon won&#8217;t even need Graphviz installed.<\/p>\n\n\n\n<p>Please find all details in the <a href=\"https:\/\/github.com\/enikao\/asciidoctor-tree\">example repository<\/a> and <a href=\"https:\/\/nikostotz.de\/blog\/tree-in-asciidoctor.html\">example HTML<\/a> \/ <a href=\"https:\/\/nikostotz.de\/blog\/tree-in-asciidoctor.pdf\">example PDF<\/a> rendering.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Showing a hierarchical tree, like a file system directory tree, in Asciidoctor is surprisingly hard. We use PlantUML to render the tree on all common platforms. This tree is rendered from the following code: It works on all Asciidoctor implementations that support asciidoctor-diagram and renders well in both HTML and PDF. Readers can select the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[],"class_list":["post-443","post","type-post","status-publish","format-standard","hentry","category-asciidoctor"],"_links":{"self":[{"href":"https:\/\/www.nikostotz.de\/blog\/wp-json\/wp\/v2\/posts\/443","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nikostotz.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nikostotz.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nikostotz.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nikostotz.de\/blog\/wp-json\/wp\/v2\/comments?post=443"}],"version-history":[{"count":11,"href":"https:\/\/www.nikostotz.de\/blog\/wp-json\/wp\/v2\/posts\/443\/revisions"}],"predecessor-version":[{"id":455,"href":"https:\/\/www.nikostotz.de\/blog\/wp-json\/wp\/v2\/posts\/443\/revisions\/455"}],"wp:attachment":[{"href":"https:\/\/www.nikostotz.de\/blog\/wp-json\/wp\/v2\/media?parent=443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nikostotz.de\/blog\/wp-json\/wp\/v2\/categories?post=443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nikostotz.de\/blog\/wp-json\/wp\/v2\/tags?post=443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}