markdown-toc icon indicating copy to clipboard operation
markdown-toc copied to clipboard

--no-firsth1 option causes "undefined" words to appear in the toc

Open trusktr opened this issue 4 years ago • 3 comments

Example without the option:

$ npx markdown-toc README.md
- [my-project](#my-project)
- [Getting started](#getting-started)
- [Usage](#usage)
  * [Example](#example)
- [API](#api)
  * [The `` element](#the--element)
    + [Attributes/Properties](#attributesproperties)
    + [Methods](#methods)
    + [Events](#events)
- [More Examples](#more-examples)
  * [Usage with [`@lume/element`](https://github.com/lume/element)](#usage-with-lumeelementhttpsgithubcomlumeelement)
  * [Usage with React](#usage-with-react)
  * [Usage with React and TypeScript](#usage-with-react-and-typescript)
  * [Usage with other view libs/frameworks](#usage-with-other-view-libsframeworks)
- [Development](#development)
  * [Test it in the examples](#test-it-in-the-examples)
  * [Test it in another project](#test-it-in-another-project)

Example with the option:

$ npx markdown-toc --no-firsth1 README.md
undefined [Getting started](#getting-started)
undefined [Usage](#usage)
- [Example](#example)
undefined [API](#api)
- [The `` element](#the--element)
  * [Attributes/Properties](#attributesproperties)
  * [Methods](#methods)
  * [Events](#events)
undefined [More Examples](#more-examples)
- [Usage with [`@lume/element`](https://github.com/lume/element)](#usage-with-lumeelementhttpsgithubcomlumeelement)
- [Usage with React](#usage-with-react)
- [Usage with React and TypeScript](#usage-with-react-and-typescript)
- [Usage with other view libs/frameworks](#usage-with-other-view-libsframeworks)
undefined [Development](#development)
- [Test it in the examples](#test-it-in-the-examples)
- [Test it in another project](#test-it-in-another-project)

trusktr avatar Feb 03 '21 16:02 trusktr

@trusktr thank you for the issue and the example. Will you also include the source README.md to help determine where the bug is occurring?

doowb avatar Feb 04 '21 15:02 doowb

It happens only when the file contains <!-- toc -->. Sample file : README.md.txt.

Without <!-- toc --> :

mycomputer$ markdown-toc --no-firsth1 README.md 
- [About](#about)
- [Requirements & installation](#requirements--installation)
  * [Python package installation](#python-package-installation)
  * [Installation from source](#installation-from-source)
  * [Docker usage](#docker-usage)
...

With <!-- toc --> :

mycomputer$ markdown-toc --no-firsth1 README.md 
undefined [Requirements & installation](#requirements--installation)
- [Python package installation](#python-package-installation)
- [Installation from source](#installation-from-source)
- [Docker usage](#docker-usage)
...

nicobo avatar Mar 18 '21 21:03 nicobo

Also it's probably a duplicate of #42 and #131

nicobo avatar Mar 18 '21 21:03 nicobo