remarkjs / remark-toc

plugin to generate a table of contents (TOC)

Home Page:https://remark.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrapping the table of contents in a `<div>`?

liambarr opened this issue · comments

Subject of the feature

Wrap the TOC in a div to allow custom stylings seperate from rest of the document.

Describe your issue here.

Problem

Just trying to styling the TOC separately to the rest of the page. If I try to wrap ### Table of Contents in a DIV it brings all the content into that div with it.

Expected behaviour

I'd like to have the TOC in it's own DIV so I can style it separately from the rest of the page.

commented

Hi Liam!
That is a custom use case not useful for most users, and hence it should go in a different plugin.
If you are going to HTML, you could create a rehype plugin, but then there is also already rehype-toc that may do what you want.

Alternatively, with your current setup, use CSS nested selectors to select the ol and lis in the <div>.

Hi Liam!
That is a custom use case not useful for most users, and hence it should go in a different plugin.
If you are going to HTML, you could create a rehype plugin, but then there is also already rehype-toc that may do what you want.

Alternatively, with your current setup, use CSS nested selectors to select the ol and lis in the <div>.

Thank you. I also just came across the + option in CSS - therefore h2#table-of-contents + ul {} will suit my needs