Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Generates tree views based on ascii-tree with beautiful icons for folders and icons

License

NotificationsYou must be signed in to change notification settings

lask79/asciidoctor-treeview

Repository files navigation

1. Features

SourceResult
[treeview]----.* .vscode** extensions.json**  settings.json* data**  config*** default.json*** full.json*** minimal.json** templates*** treeview.css.hbs*** treeview.js.hbs* .editorconfig* .eslintrc* .gitignore* .npmignore* .stylelintrc* LICENSE* package.json----

small structure result

  • No scripts used (no highlight.js or custom scripts)

  • Supports Antora and Asciidoctor standalone

  • Generates treeview based on:

    • symbol based treeview (#, *) or custom symbol

    • ascii-tree (using tree command on Linux or Windows)

    • autodetects if ascii-tree parser should be used or symbol parser

  • Calculates the right icons for folders and files based on:

    • extensions

    • file names

    • folder names

    • language ids

  • Uses the same icons as VSCode (useshttps://github.com/PKief/vscode-material-icon-theme)

  • Adds styles to the document

  • Supports dark and light mode

  • Uses different icons for dark and light mode

  • Supports callouts / conums

  • Supports different ways of retrieving the icons:

    • jsdelivr (default) ⇒ downloads from CDN

    • embedded ⇒ embeds the icons into the css as data uri

    • antora ⇒ copies icons into UI catalog

    • <custom_path> ⇒ configure your own path or url

  • Generates css based on used icons

  • Copies only the used icons to the antora UI catalog

  • Dark and light mode

    DarkLight

    treeview dark

    treeview light

2. Installation and Integration

2.1. Basic Installation

Install the extension using npm:

npm i asciidoctor-treeview

2.2. Integration with Asciidoctor

To use the extension with standalone Asciidoctor:

Register with Asciidoctor
constasciidoctor=require('@asciidoctor/core')()constasciidoctorTreeView=require('asciidoctor-treeview')constregistry=asciidoctor.Extensions.create()asciidoctorTreeView.register(registry)
Note
The extension automatically adds required CSS via theDocInfoProcessor.

2.3. Integration with Antora

The extension seamlessly integrates with Antora documentation sites. Follow these steps:

2.3.1. 1. Configure Antora Playbook

Add the extension to your Antora playbook:

antora-playbook.yml
antora:extensions:    -require:"asciidoctor-treeview/antora"
Important
Do not add asciidoctor-treeview toasciidoc.extensions. This will prevent proper CSS integration.

2.3.2. 2. Set Up UI Integration

The extension requires a small modification to your Antora UI bundle to include its styles. You have two options:

Option A: Modify UI Bundle

Add the following line topartials/head-styles.hbs in your UI bundle:

{{>treeview-styles}}
Option B: Use Supplemental UI (Recommended)

If you’re using the default UI bundle or prefer not to modify your custom bundle, create a supplemental UI file:

supplemental-ui/partials/head-styles.hbs
<linkrel="stylesheet"href="{{{uiRootPath}}}/css/site.css">{{> treeview-styles }}

The extension providestreeview-styles.hbs which includes:

<linkrel="stylesheet"href="{{{uiRootPath}}}/css/treeview.css">
Note
Thetreeview.css file contains styles necessary for proper rendering and overrides some styles from theAntora UI Default.

2.4. Integration with VSCode

For VSCode users:

VSCode Integration
// Add to .asciidoctor/lib/asciidoctor-treeview.jsmodule.exports=require('asciidoctor-treeview')

3. Usage

TypeSourceResult

ascii-tree

[treeview]----.├── .vscode│   ├── extensions.json│   └── settings.json├── data│   ├── config│   │   ├── default.json│   │   ├── full.json│   │   └── minimal.json│   └── templates│       ├── treeview.css.hbs│       └── treeview.js.hbs├── .editorconfig├── .eslintrc├── .gitignore├── .npmignore├── .stylelintrc├── LICENSE└── package.json----

small structure result

Hash Symbol

[treeview]----.# .vscode## extensions.json##  settings.json# data##  config### default.json### full.json### minimal.json## templates### treeview.css.hbs### treeview.js.hbs# .editorconfig# .eslintrc# .gitignore# .npmignore# .stylelintrc# LICENSE# package.json----

small structure result

* Symbol

[treeview]----.* .vscode** extensions.json**  settings.json* data**  config*** default.json*** full.json*** minimal.json** templates*** treeview.css.hbs*** treeview.js.hbs* .editorconfig* .eslintrc* .gitignore* .npmignore* .stylelintrc* LICENSE* package.json----

small structure result

Custom Symbol

[treeview,symbol="-"]----.- .vscode-- extensions.json--  settings.json- data--  config--- default.json--- full.json--- minimal.json-- templates--- treeview.css.hbs--- treeview.js.hbs- .editorconfig- .eslintrc- .gitignore- .npmignore- .stylelintrc- LICENSE- package.json- test.hcl----

small structure result

4. Configuration

4.1. Asciidoc Attributes

4.1.1. treeview-theme

Default: dark

  • Usetreeview-theme attribute on document

:treeview-theme: light
  • Use attribute on treeview block

[treeview,theme=light]----<your tree>----[treeview,theme=dark]----<your tree>----

4.1.2. treeview-icon-source

Default: jsdelivr

  • Usetreeview-icon-source attribute on document

  • Supported values:

    • jsdelivr (default) ⇒ downloads from CDN

    • embedded ⇒ embeds the icons into the css as data-uri

    • antora ⇒ copies icons into UI catalog

    • <custom_path> ⇒ configure your own or url to the folder that contains the icons.

Examples:

Embed icons as data-uri in CSS
= Document Title:treeview-icon-source: embedded
Use custom url
= Document Title:treeview-icon-source: https://example.com/cdn/icons

The icon name like file.svg will be added as suffix to the given url.

4.2. Antora

antora:extensions:    -require:"asciidoctor-treeview/antora"icon_source:antora# or embedded or jsdelivr

Default: antora

  • Useicon-source attribute on document

  • Supported values:

    • antora (default) ⇒ copies icons into UI catalog

    • jsdelivr ⇒ downloads from CDN

    • embedded ⇒ embeds the icons into the css as data-uri

Warning
The asciidoctor attributetreeview-icon-source will be ignored when antora is used.

5. Symbol Based Parser

  • Symbols * and # are already autodetected.

  • If you want to use a custom symbol like '-' then you need to configure it on the treeview block.

Autodetected symbol #
[treeview,symbol="-"]----.- .vscode-- extensions.json--  settings.json----

6. HowTos

I want to mark a line as folder even when it does not have children

Put a/ at the end of the name.Then that line will be marked as a folder.

[treeview]----.# folder/# second-folder/----
I want to add comments to a line

Put// at the end of the line.Then that line will be marked as a comment.

[treeview]----.# README.md // this is a comment----

7. Changelog

v1.0.1

  • Improvements

    • Fixed documentation about how to use the extension in antora

    • Added github actions to validate against asciidoctor, antora and nodejs versions

v1.0.0

  • Improvements

    • Updated to material-icons-theme version 5.19.0

    • Added tests to validate antora build

  • Fixes

    • Asciidoctor-treeview plugin no longer works with Antora(#10)

    • material-icon-theme package is not set as a dependency(#11)

v1.0.0-alpha.7

  • Features

    • add support for different icon sources(#8)

      • jsdelivr (default) ⇒ downloads from CDN

      • embedded ⇒ embeds the icons into the css as data uri

      • antora ⇒ copies icons into UI catalog

      • <custom_path> ⇒ configure your own path or url

  • Refactoring

    • Now generates a treeview.css that uses urls for the different icons instead of creating image tags inside of the document.

    • Uses roles on an <i> tag to define the icons.

    • There are now new dependencies tohandlebars andmaterial-icons-theme.

    • Collects all used icons and uses them to generate the css and copies only the used icons to the UI catalog

v1.0.0-alpha.6

  • Features

    • allow comments on lines(#6)

    • mark lines as folders (see HowTos)

  • Fixes

    • do not render empty lines as files without name allow comments on lines(#5)

About

Generates tree views based on ascii-tree with beautiful icons for folders and icons

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp