facelessuser / MarkdownPreview

Markdown preview and build plugin for Sublime Text https://facelessuser.github.io/MarkdownPreview/
Other
405 stars 53 forks source link

anchor link is not working #167

Closed itboone closed 1 year ago

itboone commented 1 year ago

It should be possible to use cros-reference to link information inside a document.

For example:clicking on the sub directory should redirect to the corresponding title, but it is not working.

Title

sub1

Take me to pookie

it should be the correct markdown syntax to jump to the anchor point named pookie.

sub2

To insert an anchor point of that name use HTML:

<a id="pookie">I'm pookie</a>

sub3

Markdown doesn't seem to mind where you put the anchor point. A useful place to put it is in a header.

This feature does not work in markdown-preview.


I'm pookie

facelessuser commented 1 year ago

I'm not sure I understand the claim "not working". You would need to provide more information. You can see in this gif that I used Markdown Preview to generate the HTML from the Markdown you posted and the references work fine.

pookie

itboone commented 1 year ago

Environment:

{
  "browser": "default",
  "parser": "markdown",
  "build_action": "browser",
  "github_mode": "markdown",
  "enable_highlight": true,
}

The following is the HTML document generated with MarkdownPreview Plugin:

<body><article class="markdown-body"><p>It should be possible to use cros-reference to link information inside a document.</p>
<p>For example:clicking on the sub directory should redirect to the corresponding title, but it is not working.</p>
<h2><a id="user-content-title" class="anchor" aria-hidden="true" href="#title"><span aria-hidden="true" class="octicon octicon-link"></span></a>Title</h2>
<ul>
<li><a href="#sub1">sub1</a></li>
<li><a href="#sub2">sub2</a></li>
<li><a href="#sub2">sub3</a></li>
</ul>
<h3><a id="user-content-sub1" class="anchor" aria-hidden="true" href="#sub1"><span aria-hidden="true" class="octicon octicon-link"></span></a>sub1</h3>
<p><em><strong>Take me to <a href="#pookie">pookie</a></strong></em></p>
<p>it should be the correct markdown syntax to jump to the anchor point named pookie.</p>
<h3><a id="user-content-sub2" class="anchor" aria-hidden="true" href="#sub2"><span aria-hidden="true" class="octicon octicon-link"></span></a>sub2</h3>
<p>To insert an anchor point of that name use HTML:</p>
<p><code>&lt;a id="pookie"&gt;I'm pookie&lt;/a&gt;</code></p>
<h3><a id="user-content-sub3" class="anchor" aria-hidden="true" href="#sub3"><span aria-hidden="true" class="octicon octicon-link"></span></a>sub3</h3>
<p>Markdown doesn't seem to mind where you put the anchor point. A useful place to put it is in a header.</p>
<p>This feature does not work in markdown-preview.</p>
<hr>
<blockquote>
<p><strong><a id="user-content-pookie">I'm pookie</a></strong></p>
</blockquote>
<hr>
</article></body>

003328

As you can see, the tag id generated in the source code is wrong, it should be the same as the title!

facelessuser commented 1 year ago

You did not mention you were using GitHub Markdown. Please read this: https://facelessuser.github.io/MarkdownPreview/usage/?h=github#parsing-github-flavored-markdown.

You'll want to enable github_inject_header_ids.