vimwiki icon indicating copy to clipboard operation
vimwiki copied to clipboard

Identical IDs for div and h-tags

Open Nudin opened this issue 6 years ago • 4 comments

Currently a heading like == foo == is converted to something like <div id="foo"><h2 id="foo">foo</h2></div> – this is invalid HTML, since id's must be unique.

Nudin avatar Apr 28 '18 00:04 Nudin

Note corresponding code is in function process_tag_h() in html.vim.

TODO:

  • [ ] understand for what the div is good for.

Nudin avatar Apr 28 '18 00:04 Nudin

There are two ways to make a link to an anchor in Vimwiki: [file#anchor] and [file#header1#header2#anchor], where you provide the complete header hierarchy. Because of this, an anchor needs two id's. The div is just a dummy tag so that you can give two id's to one header.

EinfachToll avatar May 18 '18 19:05 EinfachToll

Looks like this is only an issue if there isn't higher level header.

For example:

= Header 1 =

== foo ==

Renders:

<div id="Header 1-foo"><h2 id="foo" class="header"><a href="#Header 1-foo">foo</a></h2></div>

It seems like this is fairly harmless unless trying to use the id with javascript or something.

ranebrown avatar Mar 31 '19 22:03 ranebrown

I just noticed this while looking at @chipsenkbeil's vimwiki-rs HTML generation, where it's duplicated.

brennen avatar May 30 '21 18:05 brennen