yangshun / tree-node-cli

🌲 Node.js library to list the contents of directories in a tree-like format, similar to the Linux tree command
MIT License
234 stars 26 forks source link

feature_request(option): Markdown output #11

Closed Kristinita closed 2 years ago

Kristinita commented 5 years ago

1. Summary

It would be nice, if would be possible print output to Markdown format.

2. Example data

Simple tree structure:

KiraTreeNodeCLI/
├── KiraDirectory/
│   └── KiraSecondFile.txt
└── KiraFirstFile.txt

3. Expected result

# KiraTreeNodeCLI

1. KiraFirstFile.txt

## KiraDirectory

1. KiraSecondFile.txt

4. Argumentation

I want to publish my big list of books, so that it can be conveniently referenced. For example, that would be possible show my Astronomy books to other users, I could share link https://KiraExample.com/KiraBooksList#Astronomy; Physics books — https://KiraExample.com/KiraBooksList#Physics and so on.

Yes, I know regular expressions. But currently, I have tree → Markdown conversion difficulties, because I can't do, that files would be higher than directories in output (KiraFirstFile.txt than KiraDirectory/).

5. Examples of expected behavior

5.1. Markdown format

It would be very nice, if tree-node-cli can print output in Markdown format directly. For example, if I will run command:

tree --markdown

I will get the expected result from section «Expected result»:

# KiraTreeNodeCLI

1. KiraFirstFile.txt

## KiraDirectory

1. KiraSecondFile.txt

5.2. dirs-end

If you are for any reason will not do conversion to Markdown, it would be nice to have at least --dirs-end option. Files in this case will always be located above the directories.

tree -F --dirs-end
KiraTreeNodeCLI/
├── KiraFirstFile.txt
└── KiraDirectory/
    └── KiraSecondFile.txt

6. Not helped

I can't find in Internet third-party tools for conversion filesystem tree structure to Markdown format.

7. Do not offer

I don't need to convert filesystem tree structure to Markdown list; please, do not offer it. I need, that directories and subdirectories would be converted to Markdown headers; please, read section «Argumentation».

Thanks.

Kristinita commented 4 years ago

Type: Question :question:

@yangshun , is any chance, that it will be implemented?

Thanks.

yangshun commented 4 years ago

Sorry it's unlikely I will work on this as the use case is very niche. You're welcome to submit Pull Requests or maintain a fork.

yangshun commented 2 years ago

We won't be working on this as it's a very niche use case. Apologies.

As a future improvement maybe we could read the file directory into a JS tree object which can then be printed in different kind of outputs. Currently we're traversing the tree and storing each line as a string to be printed