Skip to content

Instantly share code, notes, and snippets.

@ged1959
Last active November 1, 2023 05:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ged1959/8e20eeb62bb8c149024ffc331c90930f to your computer and use it in GitHub Desktop.
Save ged1959/8e20eeb62bb8c149024ffc331c90930f to your computer and use it in GitHub Desktop.
markdownに目次をつける。

Gist用markdownにする方法

Created: 18.08.18

目標

  1. Chromebookでも作成できる。
  2. 目次つき。
  3. 公開できるものも。
  4. GitHub pagesとの連携。写真、movie、twitterのため。

手順

  1. 下書きは、原則、Paper。
  2. markdownとしてdownload。
  3. Textyで調整。特に、「**」=>「###」に。
  4. CodeanywhereのNode.jsプロジェクトで目次をつける。 => 別項。
  5. Gistに登録。

目次つけ

やり方は、これで大体分かる。

使うのは、以下。

★インストール。

npm install -g doctoc

★目次を入れたい場所に以下。

<!-- START doctoc -->
<!-- END doctoc -->

localだと、以下のコマンド、は動かない。エラー。bashには、そんなcommandねえよ、と。後述のように、ただ、globalだと動く。

doctoc README.md --github

とりあえず、動いた方法。localgit initで入れて、入っているフォルダまで掘って…。うーむ。それにしても、なんで、nodeコマンドを省略しているのだろう?本当に省略?

以下では、もちろん、入れた。

markd$ node ./node_modules/doctoc/doctoc node_1.md --github

DocToccing single file "node_1.md" for github.com.

==================

"node_1.md" will be updated

Everything is OK.

まずは、globalで試す。できた。上の★のところ、3つ(doctoc入れたあとは、2つ)実行すればいい、と判明。

参考リンク

  1. Markdownに目次(TOC)を表示させる - tsunokawaのはてなダイアリー
  2. GitHub 上の Markdown が TOC(目次) を表示してくれないのでどうしようか → ツール自製したよって話 - Qiita
  3. github-markdown-toc.goでMarkdown文書の目次を自動生成 - Steel Dragon 14106
  4. メモの書き方 - Markdown応用編 #mimemo - mimemo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment