vuepress-theme-hope / vuepress-theme-hope

A vuepress theme with tons of features✨
https://theme-hope.vuejs.press
MIT License
1.97k stars 697 forks source link

[Bug] href header tag when text looks like a url #3389

Closed vordimous closed 10 months ago

vordimous commented 10 months ago

Checklist

Package name

vuepress-theme-hope

Which operating system are you using?

Describe the bug

Headers are being turned into external links when they look like a URL. This can be prevented by changing the text or adding a \ to escape the . symbol in the header.

.md content:

# test.com

## test.com

## test.coms

### test.com

### test.coms

#### test.com

#### test.coms

##### test.com

##### test.coms

produced html:

<div class="vp-page-title">
  <h1><!---->test.com</h1>
  <div class="page-info"><!----><!----></div>
  <hr />
</div>

<div class="theme-hope-content">
  <h1 id="test-com" tabindex="-1">
    <a class="header-anchor" href="#test-com" aria-hidden="true">#</a>
    <a href="http://test.com" target="_blank" rel="noopener noreferrer"
      >test.com<span
        ><span class="external-link-icon-sr-only"
          >open in new window</span
        ></span
      ></a
    >
  </h1>
  <h2 id="test-com-1" tabindex="-1">
    <a class="header-anchor" href="#test-com-1" aria-hidden="true">#</a>
    <a href="http://test.com" target="_blank" rel="noopener noreferrer"
      >test.com<span
        ><span class="external-link-icon-sr-only"
          >open in new window</span
        ></span
      ></a
    >
  </h2>
  <h2 id="test-coms" tabindex="-1">
    <a class="header-anchor" href="#test-coms" aria-hidden="true">#</a>
    test.coms
  </h2>
  <h3 id="test-com-2" tabindex="-1">
    <a class="header-anchor" href="#test-com-2" aria-hidden="true">#</a>
    <a href="http://test.com" target="_blank" rel="noopener noreferrer"
      >test.com<span
        ><span class="external-link-icon-sr-only"
          >open in new window</span
        ></span
      ></a
    >
  </h3>
  <h3 id="test-coms-1" tabindex="-1">
    <a class="header-anchor" href="#test-coms-1" aria-hidden="true">#</a>
    test.coms
  </h3>
  <h4 id="test-com-3" tabindex="-1">
    <a class="header-anchor" href="#test-com-3" aria-hidden="true">#</a>
    <a href="http://test.com" target="_blank" rel="noopener noreferrer"
      >test.com<span
        ><span class="external-link-icon-sr-only"
          >open in new window</span
        ></span
      ></a
    >
  </h4>
  <h4 id="test-coms-2" tabindex="-1">
    <a class="header-anchor" href="#test-coms-2" aria-hidden="true">#</a>
    test.coms
  </h4>
  <h5 id="test-com-4" tabindex="-1">
    <a class="header-anchor" href="#test-com-4" aria-hidden="true">#</a>
    <a href="http://test.com" target="_blank" rel="noopener noreferrer"
      >test.com<span
        ><span class="external-link-icon-sr-only"
          >open in new window</span
        ></span
      ></a
    >
  </h5>
  <h5 id="test-coms-3" tabindex="-1">
    <a class="header-anchor" href="#test-coms-3" aria-hidden="true">#</a>
    test.coms
  </h5>
</div>

Additional context

No response

Mister-Hope commented 10 months ago

Tell me why this should be a bug when you enable linkify?

vordimous commented 10 months ago

Tell me why this should be a bug when you enable linkify?

I didn't expressly enable linkify but enabled gfm. Perhaps the docs need more explicit instructions on what is also enabled when switching this flag.

Mister-Hope commented 10 months ago

https://google.com

https://google.com

https://google.com

# https://google.com

Why? This is github behavior, then why this is my responsibility to explain how GFM works?

Mister-Hope commented 10 months ago

As you can see, we are already severing a huge docs with lots of details and exaplainations.

Things like this which is somthing outside my work will not be added in docs, as users will find it harder to find out things they are looking for through docs.

Unless any provement that this is my speicial behavior, or I refuse to add any notice as they are not needed.

vordimous commented 10 months ago

Detecting links that start with http:// is an obvious implementation however the header in my docs does not have any common URL markings and isn't detected in Github as a URL.

Why? This is github behavior, then why this is my responsibility to explain how GFM works?

The linkify plugin does not behave like gfm, which is the cause for the issue and the need for clarification. Specifically, the header in my docs is event.id and would be thought of as a URL outside of a poorly written regex.

test.com

test.coms

https://test.com

https://test.coms

vordimous commented 10 months ago

Thank you for reopening the issue. I can try to submit a PR to linkify at some point, but at least users can find this thread if they run into the same issue.

github-actions[bot] commented 10 months ago

This issue is marked as stale because it has not had recent activity. Issues marked with stale will be closed if they have no activity within 3 days.

Mister-Hope commented 10 months ago

MarkdownIt and Github treat link text differently, and we do not have plans to fix this.

A special note is added in docs.