328

Jekyll のブログ投稿でディレクトリとファイル構造について説明したいのですが、Markdown はそのようなものを出力する適切な方法を提供しますか?

たとえば、Jekyll Web サイトのこのリンクで、ディレクトリとファイルの構造がページに非常にきれいに出力されていることがわかります。

.
├── _config.yml
├── _drafts
│   ├── begin-with-the-crazy-ideas.textile
│   └── on-simplicity-in-technology.markdown
├── _includes
│   ├── footer.html
│   └── header.html
├── _layouts
│   ├── default.html
│   └── post.html
├── _posts
│   ├── 2007-10-29-why-every-programmer-should-play-nethack.textile
│   └── 2009-04-26-barcamp-boston-4-roundup.textile
├── _data
│   └── members.yml
├── _site
└── index.html

上記の行ブロック文字は Unicode であると思います (こちらの回答で説明されています) が、Markdown または別のブラウザーがそれらをどのように処理するかはわかりません。おそらく上記の Unicode 文字として出力される、これを行う何らかの方法が Markdown に含まれていることを期待していました。

4

12 に答える 12

359

別のリポジトリの例に従い、ディレクトリ構造を 3 つのバッククォート ( ```)のペアで囲みました。

```
project
│   README.md
│   file001.txt    
│
└───folder1
│   │   file011.txt
│   │   file012.txt
│   │
│   └───subfolder1
│       │   file111.txt
│       │   file112.txt
│       │   ...
│   
└───folder2
    │   file021.txt
    │   file022.txt
```
于 2014-07-25T18:10:59.307 に答える
48

ツリーを使用して、例に非常に似たものを生成できます。出力を取得したら、それを<pre>タグでラップして、プレーン テキストの書式設定を保持できます。

于 2013-10-31T05:31:12.427 に答える
36

すでに推奨されているように、使用できますtree。ただし、再構成されたテキストと一緒に使用するには、いくつかの追加パラメーターが必要でした。

PDFの生成に使用している場合、標準tree出力は印刷されませんpandoc

tree --dirsfirst --charset=ascii /path/to/directoryASCII次のように、ドキュメントに統合できる素敵なツリーが生成されます。

.. code::
.
|-- ContentStore
|   |-- de-DE
|   |   |-- art.mshc
|   |   |-- artnoloc.mshc
|   |   |-- clientserver.mshc
|   |   |-- noarm.mshc
|   |   |-- resources.mshc
|   |   `-- windowsclient.mshc
|   `-- en-US
|       |-- art.mshc
|       |-- artnoloc.mshc
|       |-- clientserver.mshc
|       |-- noarm.mshc
|       |-- resources.mshc
|       `-- windowsclient.mshc
`-- IndexStore
    |-- de-DE
    |   |-- art.mshi
    |   |-- artnoloc.mshi
    |   |-- clientserver.mshi
    |   |-- noarm.mshi
    |   |-- resources.mshi
    |   `-- windowsclient.mshi
    `-- en-US
        |-- art.mshi
        |-- artnoloc.mshi
        |-- clientserver.mshi
        |-- noarm.mshi
        |-- resources.mshi
        `-- windowsclient.mshi
于 2016-05-27T08:36:33.413 に答える
8

これを Dropbox ファイル リスト用にスクリプト化しました。

sed後に続くシンボリックリンクされたファイル/フォルダーパスのフルパスを削除するために使用されます->

残念ながら、タブは失われています。を使用zshすると、タブを保持できます。

!/usr/bin/env バッシュ

#!/usr/bin/env zsh

F1='index-2.md' #With hyperlinks
F2='index.md'

if [ -e $F1 ];then
    rm $F1
fi

if [ -e $F2 ];then
    rm $F2
fi

DATA=`tree --dirsfirst -t -Rl --noreport | \
    sed 's/->.*$//g'`             # Remove symlink adress and ->

echo -e '```\n' ${DATA} '\n```' > $F1  # Markdown needs triple back ticks for <pre>

# With the power of piping, creating HTML tree than pipe it
# to html2markdown program, creates cool markdown file with hyperlinks.

DATA=`tree --dirsfirst -t -Rl --noreport -H http://guneysu.pancakeapps.com`
echo $DATA | \
    sed 's/\r\r/\n/g' | \
    html2markdown | \
    sed '/^\s*$/d' | \
    sed 's/\# Directory Tree//g' | \
        > $F2

このような出力:

```
 .
├── 2013 
│   └── index.markdown
├── 2014 
│   └── index.markdown
├── 2015 
│   └── index.markdown
├── _posts 
│   └── 2014-12-27-2014-yili-degerlendirmesi.markdown
├── _stash 
└── update.sh 
```

[BASE_URL/](BASE_URL/)
├── [2013](BASE_URL/2013/)
│   └── [index.markdown](BASE_URL/2013/index.markdown)
├── [2014](BASE_URL/2014/)
│   └── [index.markdown](BASE_URL/2014/index.markdown)
├── [2015](BASE_URL/2015/)
│   └── [index.markdown](BASE_URL/2015/index.markdown)
├── [_posts](BASE_URL/_posts/)
│   └── [2014-12-27-2014-yili-degerlendirmesi.markdown](_posts/2014-12-27-2014-yili-degerlendirmesi.markdown)
├── [_stash](BASE_URL/_stash/)
├── [index-2.md](BASE_URL/index-2.md)
└── [update.sh](BASE_URL/update.sh)
* * *
tree v1.6.0 © 1996 - 2011 by Steve Baker and Thomas Moore
HTML output hacked and copyleft © 1998 by Francesc Rocher
Charsets / OS/2 support © 2001 by Kyosuke Tokoro
于 2014-12-27T15:02:23.660 に答える
1

動的に生成したい場合は、Frontend-mdを使用することをお勧めします。使い方は簡単です。

于 2015-11-06T11:13:09.067 に答える