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

include section the toc is under in the toc

Open PlasmaHH opened this issue 6 years ago • 6 comments
trafficstars

Currently it looks like the plugin ignores all headings above the point where you insert it. This leads to the case that when it is inserted under a # heading and after the toc comes a ## heading, the generated markdown list starts with an indentation, which will not be rendered as part of the list. Therefore the plugin should have an option to also include all the headings that are before its insert point

PlasmaHH avatar Mar 15 '19 19:03 PlasmaHH

Thanks for your suggestion.

Let me retell your scene,

# heading1-1

<-- you want to insert toc here

## heading2-1

# heading1-2

## heading2-2

is that right?

mzlogin avatar Mar 16 '19 13:03 mzlogin

Yes, exactly. Though other positions should probably work too ;)

PlasmaHH avatar Mar 17 '19 15:03 PlasmaHH

I think I get the drift. But I want to know, why don't you insert toc in the following two positions

<------------------- position 1

# heading1-1

## heading2-1

<------------------- position 2

# heading1-2

## heading2-2

mzlogin avatar Mar 19 '19 13:03 mzlogin

This is just the style my/our readmes are constructed, for a bit more context imagine:

Project

TOC

## Abstract # Chapter 1 .... # Chapter 2 ....

The documents basically have an introductionary level1 chapter that contains the toc as a part of the introduction.

Btw. I found a hackish workaround, which relies on what maybe would be considered a bug by some. Putting # Project within html comments just after the toc makes it not displayed as text but parsed by the toc plugin. However this might be considered a bug in case it is expected to ignore things that would not be rendered. Also I am not sure if this works for all markdown renderers.

PlasmaHH avatar Mar 20 '19 08:03 PlasmaHH

Hi~I add an option g:vmt_include_headings_before to support this.

So you can add let g:vmt_include_headings_before = 1 in your vimrc file now.

Could you please feedback your result? Thanks a lot!

mzlogin avatar Mar 20 '19 16:03 mzlogin

Indeed it works as expected

PlasmaHH avatar Mar 20 '19 20:03 PlasmaHH