398 lines
24 KiB
HTML

<!DOCTYPE html>
<html lang="en" dir="ltr" itemscope itemtype="http://schema.org/Article" data-r-output-format="print">
<head>
<meta charset="utf-8">
<meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0, minimum-scale=1.0">
<meta name="generator" content="Hugo 0.145.0">
<meta name="generator" content="Relearn 7.6.1+b0c6bb558d7728ac4535a2ac677c5f47297203cc">
<meta name="description" content="Display a list as a tree">
<meta name="author" content="Sören Weber">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://mcshelby.github.io/hugo-theme-relearn/images/hero.png">
<meta name="twitter:title" content="Tree :: Hugo Relearn Theme">
<meta name="twitter:description" content="Display a list as a tree">
<meta property="og:url" content="https://mcshelby.github.io/hugo-theme-relearn/shortcodes/tree/index.html">
<meta property="og:site_name" content="Hugo Relearn Theme">
<meta property="og:title" content="Tree :: Hugo Relearn Theme">
<meta property="og:description" content="Display a list as a tree">
<meta property="og:locale" content="en">
<meta property="og:type" content="article">
<meta property="article:section" content="Shortcodes">
<meta property="og:image" content="https://mcshelby.github.io/hugo-theme-relearn/images/hero.png">
<meta itemprop="name" content="Tree :: Hugo Relearn Theme">
<meta itemprop="description" content="Display a list as a tree">
<meta itemprop="wordCount" content="445">
<meta itemprop="image" content="https://mcshelby.github.io/hugo-theme-relearn/images/hero.png">
<meta itemprop="keywords" content="Howto,Reference">
<title>Tree :: Hugo Relearn Theme</title>
<link href="https://mcshelby.github.io/hugo-theme-relearn/shortcodes/tree/index.html" rel="alternate" hreflang="x-default">
<link href="https://mcshelby.github.io/hugo-theme-relearn/shortcodes/tree/index.html" rel="alternate" hreflang="en">
<link href="https://mcshelby.github.io/hugo-theme-relearn/pir/shortcodes/tree/index.html" rel="alternate" hreflang="art-x-pir">
<link href="https://mcshelby.github.io/hugo-theme-relearn/shortcodes/tree/index.html" rel="canonical" type="text/html" title="Tree :: Hugo Relearn Theme">
<link href="/hugo-theme-relearn/shortcodes/tree/index.xml" rel="alternate" type="application/rss+xml" title="Tree :: Hugo Relearn Theme">
<link href="/hugo-theme-relearn/images/logo.svg?1744314146" rel="icon" type="image/svg+xml">
<link href="/hugo-theme-relearn/fonts/fontawesome/css/fontawesome-all.min.css?1744314146" rel="stylesheet" media="print" onload="this.media='all';this.onload=null;"><noscript><link href="/hugo-theme-relearn/fonts/fontawesome/css/fontawesome-all.min.css?1744314146" rel="stylesheet"></noscript>
<link href="/hugo-theme-relearn/css/perfect-scrollbar/perfect-scrollbar.min.css?1744314146" rel="stylesheet">
<link href="/hugo-theme-relearn/css/theme.min.css?1744314146" rel="stylesheet">
<link href="/hugo-theme-relearn/css/format-print.min.css?1744314146" rel="stylesheet" id="R-format-style">
<link href="/hugo-theme-relearn/css/auto-complete/auto-complete.min.css?1744314146" rel="stylesheet">
<script src="/hugo-theme-relearn/js/auto-complete/auto-complete.min.js?1744314146" defer></script>
<script src="/hugo-theme-relearn/js/lunr/lunr.min.js?1744314146" defer></script>
<script src="/hugo-theme-relearn/js/lunr/lunr.stemmer.support.min.js?1744314146" defer></script>
<script src="/hugo-theme-relearn/js/lunr/lunr.multi.min.js?1744314146" defer></script>
<script src="/hugo-theme-relearn/js/lunr/lunr.en.min.js?1744314146" defer></script>
<script src="/hugo-theme-relearn/js/search.min.js?1744314146" defer></script>
<script>
window.relearn = window.relearn || {};
// configuration
window.relearn.min = `.min`;
window.relearn.path='\/shortcodes\/tree\/index.html';
window.relearn.relBasePath='..\/..';
window.relearn.relBaseUri='..\/..\/..';
window.relearn.absBaseUri='https:\/\/mcshelby.github.io\/hugo-theme-relearn';
window.relearn.contentLangs=['en'];
window.relearn.index_js_url="/hugo-theme-relearn/searchindex.en.js?1744314146";
window.relearn.disableAnchorCopy=false;
window.relearn.disableAnchorScrolling=false;
window.relearn.disableInlineCopyToClipboard=true;
window.relearn.enableBlockCodeWrap=true;
// legal
window.relearn.getItem = (s,n) => {return s.getItem(n)};
window.relearn.setItem = (s,n,v) => {return s.setItem(n,v)};
window.relearn.removeItem = (s,n) => {return s.removeItem(n)};
// variant stuff
window.relearn.themevariants = [ 'relearn-auto', 'relearn-dark', 'relearn-light', 'relearn-bright', 'zen-auto', 'zen-dark', 'zen-light', 'retro-auto', 'neon', 'learn', 'blue', 'green', 'red' ];
window.relearn.customvariantname = "my-custom-variant";
window.relearn.changeVariant = function(variant) {
var oldVariant = document.documentElement.dataset.rThemeVariant;
window.relearn.setItem(window.localStorage, window.relearn.absBaseUri + "/variant", variant);
document.documentElement.dataset.rThemeVariant = variant;
if (oldVariant != variant) {
document.dispatchEvent( new CustomEvent('themeVariantLoaded', { detail: { variant, oldVariant } }) );
window.relearn.markVariant();
}
}
window.relearn.markVariant = function() {
var variant = window.relearn.getItem(window.localStorage, window.relearn.absBaseUri + "/variant");
document.querySelectorAll(".R-variantswitcher select").forEach((select) => {select.value = variant;});
}
window.relearn.initVariant = function() {
var variant = window.relearn.getItem(window.localStorage, window.relearn.absBaseUri + "/variant") ?? "";
if( variant == window.relearn.customvariantname ){
}else if( !variant || !window.relearn.themevariants.includes(variant) ){
variant = window.relearn.themevariants[0];
window.relearn.setItem(window.localStorage, window.relearn.absBaseUri + "/variant", variant);
}
document.documentElement.dataset.rThemeVariant = variant;
}
window.relearn.initVariant();
window.relearn.markVariant();
// translations
window.T_Copy_to_clipboard = `Copy to clipboard`;
window.T_Copied_to_clipboard = `Copied to clipboard!`;
window.T_Copy_link_to_clipboard = `Copy link to clipboard`;
window.T_Link_copied_to_clipboard = `Copied link to clipboard!`;
window.T_Reset_view = `Reset view`;
window.T_View_reset = `View reset!`;
window.T_No_results_found = `No results found for "{0}"`;
window.T_N_results_found = `{1} results found for "{0}"`;
</script>
<script src="/hugo-theme-relearn/js/variant.min.js?1744314146"></script>
<style>
#R-body img.bg-white {
background-color: white;
}
#R-logo {
font-size: 1.875rem;
margin-bottom: -.666rem;
margin-top: -.666rem;
max-width: 100%;
width: 14.125rem;
}
@media only all and (max-width: 59.999rem) {
#R-logo {
font-size: 1.5625rem;
margin-bottom: -.1875rem;
margin-top: -.1875rem;
}
}
#R-logo svg {
display: inline-block;
opacity: .945;
vertical-align: middle;
width: 29% !important;
}
@media only all and (max-width: 59.999rem) {
#R-logo svg {
width: 24.5% !important;
}
}
#R-logo svg * {
opacity: .945;
}
#R-logo .logo-title{
display: inline-block;
text-align: left;
text-wrap: wrap;
overflow-wrap: break-word;
vertical-align: middle;
width: 4.5em;
}
</style>
</head>
<body class="mobile-support print" data-url="/hugo-theme-relearn/shortcodes/tree/index.html">
<div id="R-body" class="default-animation">
<div id="R-body-overlay"></div>
<nav id="R-topbar">
<div class="topbar-wrapper">
<div class="topbar-sidebar-divider"></div>
<div class="topbar-area topbar-area-start" data-area="start">
<div class="topbar-button topbar-button-sidebar" data-content-empty="disable" data-width-s="show" data-width-m="hide" data-width-l="hide"><button class="topbar-control" onclick="toggleNav()" type="button" title="Menu (CTRL&#43;ALT&#43;n)"><i class="fa-fw fas fa-bars"></i></button>
</div>
<div class="topbar-button topbar-button-toc" data-content-empty="hide" data-width-s="show" data-width-m="show" data-width-l="show"><button class="topbar-control" onclick="toggleTopbarFlyout(this)" type="button" title="Table of Contents (CTRL&#43;ALT&#43;t)"><i class="fa-fw fas fa-list-alt"></i></button>
<div class="topbar-content">
<div class="topbar-content-wrapper">
<nav class="TableOfContents">
<ul>
<li><a href="#usage">Usage</a>
<ul>
<li><a href="#parameter">Parameter</a></li>
<li><a href="#item-syntax">Item Syntax</a></li>
</ul>
</li>
<li><a href="#examples">Examples</a>
<ul>
<li><a href="#bigger-example">Bigger example</a></li>
</ul>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<ol class="topbar-breadcrumbs breadcrumbs highlightable" itemscope itemtype="http://schema.org/BreadcrumbList">
<li itemscope itemtype="https://schema.org/ListItem" itemprop="itemListElement" class="a11y-only"><a itemprop="item" href="/hugo-theme-relearn/index.html"><span itemprop="name">Hugo Relearn Theme</span></a><meta itemprop="position" content="1">&nbsp;>&nbsp;</li>
<li itemscope itemtype="https://schema.org/ListItem" itemprop="itemListElement" class=""><a itemprop="item" href="/hugo-theme-relearn/shortcodes/index.html"><span itemprop="name">Shortcodes</span></a><meta itemprop="position" content="2">&nbsp;>&nbsp;</li>
<li itemscope itemtype="https://schema.org/ListItem" itemprop="itemListElement" class=""><span itemprop="name">Tree</span><meta itemprop="position" content="3"></li>
</ol>
<div class="topbar-area topbar-area-end" data-area="end">
<div class="topbar-button topbar-button-edit" data-content-empty="disable" data-width-s="area-more" data-width-m="show" data-width-l="show"><a class="topbar-control" href="https://github.com/McShelby/hugo-theme-relearn/edit/main/docs/content/shortcodes/tree.en.md" rel="external" target="_self" title="Edit (CTRL+ALT+w)"><i class="fa-fw fas fa-pen"></i></a>
</div>
<div class="topbar-button topbar-button-print" data-content-empty="disable" data-width-s="area-more" data-width-m="show" data-width-l="show"><a class="topbar-control" href="/hugo-theme-relearn/shortcodes/tree/index.print.html" title="Print whole chapter (CTRL+ALT+p)"><i class="fa-fw fas fa-print"></i></a>
</div>
<div class="topbar-button topbar-button-prev" data-content-empty="disable" data-width-s="show" data-width-m="show" data-width-l="show"><a class="topbar-control" href="/hugo-theme-relearn/shortcodes/tabs/index.html" title="Tabs (🡐)"><i class="fa-fw fas fa-chevron-left"></i></a>
</div>
<div class="topbar-button topbar-button-next" data-content-empty="disable" data-width-s="show" data-width-m="show" data-width-l="show"><span class="topbar-control"><i class="fa-fw fas fa-chevron-right"></i></span>
</div>
<div class="topbar-button topbar-button-more" data-content-empty="hide" data-width-s="show" data-width-m="show" data-width-l="show"><button class="topbar-control" onclick="toggleTopbarFlyout(this)" type="button" title="More"><i class="fa-fw fas fa-ellipsis-v"></i></button>
<div class="topbar-content">
<div class="topbar-content-wrapper">
<div class="topbar-area topbar-area-more" data-area="more">
</div>
</div>
</div>
</div>
</div>
</div>
</nav>
<div id="R-main-overlay"></div>
<main id="R-body-inner" class="highlightable shortcodes" tabindex="-1">
<div class="flex-block-wrapper">
<article class="default">
<header class="headline">
</header>
<h1 id="tree">Tree</h1>
<p>The <code>tree</code> shortcode displays a list as a tree with configurable icons and colors.</p>
<div class="list-tree"><ul>
<li><i class="fa-fw fas fa-folder"></i><span>home</span><ul>
<li><i class="fa-fw fas fa-folder"></i><span><a href="http://example.com" rel="external" target="_self">.config</a></span></li>
<li><i class="fa-fw fas fa-folder cstyle magic"></i><span>My Documents</span><ul>
<li><i class="fa-fw fab fa-php" style="color: #888cc4;"></i><span>home.php</span></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<h2 id="usage">Usage</h2>
<div class="tab-panel" data-tab-group="shortcode-parameter">
<div class="tab-nav">
<div class="tab-nav-title">&#8203;</div>
<button
data-tab-item="codefence"
class="tab-nav-button tab-panel-style cstyle initial active" tabindex="-1"
onclick="switchTab('shortcode-parameter','codefence')"
>
<span class="tab-nav-text">codefence</span>
</button>
<button
data-tab-item="shortcode"
class="tab-nav-button tab-panel-style cstyle initial"
onclick="switchTab('shortcode-parameter','shortcode')"
>
<span class="tab-nav-text">shortcode</span>
</button>
<button
data-tab-item="partial"
class="tab-nav-button tab-panel-style cstyle initial"
onclick="switchTab('shortcode-parameter','partial')"
>
<span class="tab-nav-text">partial</span>
</button>
</div>
<div class="tab-content-container">
<div
data-tab-item="codefence"
class="tab-content tab-panel-style cstyle initial active">
<div class="tab-content-text">
<div class="highlight wrap-code" dir="auto"><pre tabindex="0" class="chroma"><code class="language-md" data-lang="md"><span class="line"><span class="cl"><span class="s">```tree
</span></span></span><span class="line"><span class="cl"><span class="s"></span>- home | folder
</span></span><span class="line"><span class="cl"> - [.config](http://example.com) | folder
</span></span><span class="line"><span class="cl"> - My Documents | folder | magic
</span></span><span class="line"><span class="cl"> - home.php | fa-fw fab fa-php | #888cc4
</span></span><span class="line"><span class="cl"><span class="s">```</span></span></span></code></pre></div>
</div>
</div>
<div
data-tab-item="shortcode"
class="tab-content tab-panel-style cstyle initial">
<div class="tab-content-text">
<div class="highlight wrap-code" dir="auto"><pre tabindex="0" class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="p">{{</span><span class="o">%</span> <span class="nx">tree</span> <span class="o">%</span><span class="p">}}</span>
</span></span><span class="line"><span class="cl"><span class="o">-</span> <span class="nx">home</span> <span class="p">|</span> <span class="nx">folder</span>
</span></span><span class="line"><span class="cl"> <span class="o">-</span> <span class="p">[.</span><span class="nx">config</span><span class="p">](</span><span class="nx">http</span><span class="p">:</span><span class="c1">//example.com) | folder</span>
</span></span><span class="line"><span class="cl"> <span class="o">-</span> <span class="nx">My</span> <span class="nx">Documents</span> <span class="p">|</span> <span class="nx">folder</span> <span class="p">|</span> <span class="nx">magic</span>
</span></span><span class="line"><span class="cl"> <span class="o">-</span> <span class="nx">home</span><span class="p">.</span><span class="nx">php</span> <span class="p">|</span> <span class="nx">fa</span><span class="o">-</span><span class="nx">fw</span> <span class="nx">fab</span> <span class="nx">fa</span><span class="o">-</span><span class="nx">php</span> <span class="p">|</span> <span class="err">#</span><span class="mi">888</span><span class="nx">cc4</span>
</span></span><span class="line"><span class="cl"><span class="p">{{</span><span class="o">%</span> <span class="o">/</span><span class="nx">tree</span> <span class="o">%</span><span class="p">}}</span></span></span></code></pre></div>
</div>
</div>
<div
data-tab-item="partial"
class="tab-content tab-panel-style cstyle initial">
<div class="tab-content-text">
<div class="highlight wrap-code" dir="auto"><pre tabindex="0" class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="p">{{</span> <span class="nx">partial</span> <span class="s">&#34;shortcodes/tree.html&#34;</span> <span class="p">(</span><span class="nx">dict</span>
</span></span><span class="line"><span class="cl"> <span class="s">&#34;page&#34;</span> <span class="p">.</span>
</span></span><span class="line"><span class="cl"> <span class="s">&#34;content&#34;</span> <span class="s">`- home | folder
</span></span></span><span class="line"><span class="cl"><span class="s"> - [.config](http://example.com) | folder
</span></span></span><span class="line"><span class="cl"><span class="s"> - My Documents | folder | magic
</span></span></span><span class="line"><span class="cl"><span class="s"> - home.php | fa-fw fab fa-php | #888cc4`</span>
</span></span><span class="line"><span class="cl"><span class="p">)}}</span></span></span></code></pre></div>
</div>
</div>
</div>
</div>
<p>Codefence syntax is widely available in other Markdown parsers like GitHub and therefore is the recommend syntax for generating portable Markdown.</p>
<h3 id="parameter">Parameter</h3>
<table>
<thead>
<tr>
<th>Name</th>
<th>Default</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
<tr>
<td><em><strong>&lt;content&gt;</strong></em></td>
<td><em>&lt;empty&gt;</em></td>
<td>Your list as Markdown.</td>
</tr>
</tbody>
</table>
<h3 id="item-syntax">Item Syntax</h3>
<p><code>&lt;NAME&gt;</code> [ <code>|</code> <code>&lt;ICON&gt;</code> [ <code>|</code> <code>&lt;COLOR&gt;</code> ] ]</p>
<p>The <strong>NAME</strong> can be followed by an optional pipe (<code>|</code>) to define an <strong>ICON</strong> and further optional pipe to define the icon&rsquo;s <strong>COLOR</strong>.</p>
<ul>
<li>
<p><strong>ICON</strong>: <a href="/hugo-theme-relearn/shortcodes/icon/index.html#finding-an-icon">Font Awesome icon name</a> set to the left of the <strong>NAME</strong>. If you give a single string, it is selected from Font Awesome&rsquo;s <a href="https://fontawesome.com/icons?d=gallery&s=solid&m=free" rel="external" target="_self">solid</a> icons. If you want to use a different set, you have to give the complete styles after the double colons. See above example for the <code>home.php</code>.</p>
</li>
<li>
<p><strong>COLOR</strong>: The <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/color_value" rel="external" target="_self">CSS color value</a> to be used. If not set, the primary color will be used.</p>
<p>You can also set a <strong>style</strong> value known from other shortcodes.</p>
<ul>
<li>by severity: <code>caution</code>, <code>important</code>, <code>info</code>, <code>note</code>, <code>tip</code>, <code>warning</code></li>
<li>by brand color: <code>primary</code>, <code>secondary</code>, <code>accent</code></li>
<li>by color: <code>blue</code>, <code>cyan</code>, <code>green</code>, <code>grey</code>, <code>magenta</code>, <code>orange</code>, <code>red</code></li>
<li>by special color: <code>default</code>, <code>transparent</code>, <code>code</code></li>
<li>you can also <a href="/hugo-theme-relearn/shortcodes/notice/index.html#defining-own-styles">define your own styles</a>.</li>
</ul>
<p>If a <strong>style</strong> and a named HTML color have the same name, the <strong>style</strong> color will be used.</p>
</li>
</ul>
<h2 id="examples">Examples</h2>
<h3 id="bigger-example">Bigger example</h3>
<p>Every possible combination</p>
<div class="highlight wrap-code" dir="auto"><pre tabindex="0" class="chroma"><code class="language-md" data-lang="md"><span class="line"><span class="cl"><span class="s">```tree
</span></span></span><span class="line"><span class="cl"><span class="s"></span>- [just name](http://example.com) | folder
</span></span><span class="line"><span class="cl"> - Documents
</span></span><span class="line"><span class="cl"> - My Documents
</span></span><span class="line"><span class="cl">- simple icons | folder
</span></span><span class="line"><span class="cl"> - Documents | folder
</span></span><span class="line"><span class="cl"> - My Documents | folder
</span></span><span class="line"><span class="cl">- not so simple icons | file-alt | secondary
</span></span><span class="line"><span class="cl"> - a.png | file-alt
</span></span><span class="line"><span class="cl"> - a with border.png | file-alt
</span></span><span class="line"><span class="cl">- mindblowing icons | fa-fw fab fa-markdown | accent
</span></span><span class="line"><span class="cl"> - text.md | fa-fw fab fa-markdown
</span></span><span class="line"><span class="cl"> - alternative text.md | fa-fw fab fa-markdown
</span></span><span class="line"><span class="cl">- and now with color | fa-fw fab fa-php
</span></span><span class="line"><span class="cl"> - script.php | fa-fw fab fa-markdown | purple
</span></span><span class="line"><span class="cl"> - alt script.php | fa-fw fab fa-markdown | #888cc4
</span></span><span class="line"><span class="cl"> - magic.php | fa-fw fab fa-markdown | magic
</span></span><span class="line"><span class="cl"><span class="s">```</span></span></span></code></pre></div>
<div class="list-tree"><ul>
<li><i class="fa-fw fas fa-folder"></i><span><a href="http://example.com" rel="external" target="_self">just name</a></span><ul>
<li>Documents</li>
<li>My Documents</li>
</ul>
</li>
<li><i class="fa-fw fas fa-folder"></i><span>simple icons</span><ul>
<li><i class="fa-fw fas fa-folder"></i><span>Documents</span></li>
<li><i class="fa-fw fas fa-folder"></i><span>My Documents</span></li>
</ul>
</li>
<li><i class="fa-fw fas fa-file-alt cstyle secondary"></i><span>not so simple icons</span><ul>
<li><i class="fa-fw fas fa-file-alt"></i><span>a.png</span></li>
<li><i class="fa-fw fas fa-file-alt"></i><span>a with border.png</span></li>
</ul>
</li>
<li><i class="fa-fw fab fa-markdown cstyle accent"></i><span>mindblowing icons</span><ul>
<li><i class="fa-fw fab fa-markdown"></i><span>text.md</span></li>
<li><i class="fa-fw fab fa-markdown"></i><span>alternative text.md</span></li>
</ul>
</li>
<li><i class="fa-fw fab fa-php"></i><span>and now with color</span><ul>
<li><i class="fa-fw fab fa-php" style="color: purple;"></i><span>script.php</span></li>
<li><i class="fa-fw fab fa-php" style="color: #888cc4;"></i><span>alt script.php</span></li>
<li><i class="fa-fw fab fa-php cstyle magic"></i><span>magic.php</span></li>
</ul>
</li>
</ul>
</div>
<footer class="footline">
<div class="R-taxonomy taxonomy-categories cstyle" title="Categories" style="--VARIABLE-TAGS-BG-color: var(--INTERNAL-TAG-BG-color);">
<i class="fa-fw fas fa-layer-group"></i>
<ul>
<li><a class="term-link" href="/hugo-theme-relearn/categories/howto/index.html">Howto</a></li>
<li><a class="term-link" href="/hugo-theme-relearn/categories/reference/index.html">Reference</a></li>
</ul>
</div>
</footer>
</article>
</div>
</main>
</div>
<script src="/hugo-theme-relearn/js/clipboard/clipboard.min.js?1744314146" defer></script>
<script src="/hugo-theme-relearn/js/perfect-scrollbar/perfect-scrollbar.min.js?1744314146" defer></script>
<script src="/hugo-theme-relearn/js/theme.min.js?1744314146" defer></script>
</body>
</html>