alexharv074 / markdown_toc

A Ruby script for generating a Markdown Table of Contents
MIT License
12 stars 6 forks source link

ToC inside code block #3

Open seamusdemora opened 4 years ago

seamusdemora commented 4 years ago

I made some changes to this document, and ran the current ver mdtoc.rb (TOP = 2; MAX = 3) on it as follows:

./mdtoc.rb ~/Documents/GitHub/seamus.github.io/MacStuff.md | pbcopy

I can see that spaces have been added to the beginning of each line, and this results in the ToC being embedded in a code block. Did I screw up the TOP/MAX settings?

alexharv074 commented 4 years ago

So I'm getting this output:

▶ ruby ../../../home/markdown_toc/mdtoc.rb /tmp/test.md 2 3 
#### Table of contents

    * [1. How to Change Where My Screenshots Are Saved?](#1-how-to-change-where-my-screenshots-are-saved)
    * [2. How to Prevent My Mac From Sleeping? ](#2-how-to-prevent-my-mac-from-sleeping-)
    * [3. How to Start (`open`) an App From the Mac OS Command Line?](#3-how-to-start-open-an-app-from-the-mac-os-command-line)
    * [4. How to Schedule an App to Run At a Specified Time?](#4-how-to-schedule-an-app-to-run-at-a-specified-time)
    * [5. How to Check the Size of a Directory?](#5-how-to-check-the-size-of-a-directory)
    * [6. How to Check Battery Status from the Command Line?](#6-how-to-check-battery-status-from-the-command-line)
    * [7. How to Send Files to the Trash from the macos Command Line?](#7-how-to-send-files-to-the-trash-from-the-macos-command-line)
    * [8. How to Find the Hardware Architecture and OS Version for My Mac?](#8-how-to-find-the-hardware-architecture-and-os-version-for-my-mac)
    * [9. How to Combine/Concatenate Multiple PDFs?](#9-how-to-combineconcatenate-multiple-pdfs)
    * [10. How to Search My Command History in `Terminal`?](#10-how-to-search-my-command-history-in-terminal)
    * [11. How to Disable Auto-Booting When Opening the Macbook Lid?](#11-how-to-disable-auto-booting-when-opening-the-macbook-lid)
    * [12. How to Copy `command line` Output to Pasteboard/Clipboard?](#12-how-to-copy-command-line-output-to-pasteboardclipboard)
    * [14. How to Show Hidden Files in Finder?](#14-how-to-show-hidden-files-in-finder)
    * [15. How to Recover a Bodged `git` Repository?](#15-how-to-recover-a-bodged-git-repository)
    * [16. How to Restore the "Lost Startup Chime"?](#16-how-to-restore-the-lost-startup-chime)
    * [17. Weirdness With `zsh` ](#17-weirdness-with-zsh-)
    * [OTHER SOURCES:](#other-sources)

Is that different to what you're getting?

seamusdemora commented 4 years ago

That looks like what I'm getting. The spaces to the left of the * result in the items 1-17 being placed in a code block. If a hyperlink(i.e. [words](URL) is inside a code block, it is not rendered in GFM as a hyperlink.

alexharv074 commented 4 years ago

@seamusdemora But the way you have written your document, 1-17 are in fact part of the heading. I would personally not use numbering there where you have. I know why you want to, but I usually remind myself: Markdown is really, really simple. It's not Microsoft Word. I adapt to what Markdown likes.