Skip to content

autoHeader not compatible with plugins that write before md content #810

@cyrilf

Description

@cyrilf

autoHeader looks for the first node in #main and if it's an h1 then it does nothing, if not it will create the auto header.
Fine.

The issue arises when using any plugin writing content before the user defined markdown.
A plugin like "Edit this Page" link plugin for instance.

autoHeader doesn't detect my H1 (because the edit link is first) and create an header.
The line responsible is here.

Screenshot from 2019-04-06 18-28-54
(in this screenshot Introduction shouldn't be here as My super title is defined.)

A solution could be that instead of looking if the 1st element is an H1 we could do instead something like: dom.getElementsByTagName('h1').length and trigger our autoHeader if it's equal to 0.

Otherwise we need to find a better way of making the distinction between user content and content added via plugins. But I'm not familiar enough with docsify codebase to find out at the moment.


If you think this my first solution is acceptable, then I could open a PR.

Metadata

Metadata

Assignees

Labels

bugconfirmed as a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions