qjebbs / vscode-markdown-extended

Extended syntaxes to built-in markdown & What you see is what you get exporter.
MIT License
123 stars 25 forks source link

Links don't work in self-contained HTML export anymore #127

Open Mutantpenguin opened 2 years ago

Mutantpenguin commented 2 years ago

Can't really say when this started, but links in self-contained HTML export don't work anymore. They exist, but clicking them doesn't do anything. I think the reason is, that the generated ids for linkable elements are generated wrong and thus the linked element can just not be found.

Example:

# Start

This is some text.
And [this](#a-heading-1) a link.

## A Heading 1

Some text.

## A Heading 2

Some other text.

Results in this html:

<!DOCTYPE html>
<html>
<head>
  <!-- I removed the head since it slowed down the preview --!>
</head>
<body class="markdown-body vscode-body vscode-light">
<div class="content">
    <h1 data-line="0" class="code-line" id="start-2">Start</h1>
<p data-line="2" class="code-line">This is some text.
And <a href="#a-heading-1" data-href="#a-heading-1">this</a> a link.</p>
<h2 data-line="5" class="code-line" id="a-heading-1-2">A Heading 1</h2>
<p data-line="7" class="code-line">Some text.</p>
<h2 data-line="9" class="code-line" id="a-heading-2-2">A Heading 2</h2>
<p data-line="11" class="code-line">Some other text.</p>
</div>

</body>
</html>

As you can see, the id for "A Heading 1" is now a-heading-1-2. So somehow the postfix -2 got added. It seems like it did so for all ids.

In another document of mine (which I can't share here) the postfix -3 got added for seemingly every id (didn't check them all since there are a quite a lot).

Mutantpenguin commented 2 years ago

Found something out: this happens when exporting multiple times during the same "session".

Each time this number gets increased by one.

Restarting VSCode fixes the problem for the next export.

ShinoharaYuuyoru commented 11 months ago

I also meets this issue. Is there anyway to clear the id generating history after finishing the exporting of current *.md to self-contained html?