Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anchor links to headers don't work #28

Closed
OskarSwierad opened this issue Apr 8, 2021 · 1 comment
Closed

Anchor links to headers don't work #28

OskarSwierad opened this issue Apr 8, 2021 · 1 comment

Comments

@OskarSwierad
Copy link

OskarSwierad commented Apr 8, 2021

Versions
Wordpress: 5.7
Documents for Git: 1.1.1

Describe the bug

Links within the page (e.g. https://example.com/#chapter2) don't scroll the page to the destination. It seems that name="" attribute is missing within the <a> tag.
It also breaks GitHub-compatible table of contents.

Paste the shortcode and the censored contents of config.json

{
  "limit": 5,
  "cache_strategy": "static",
  "cache_ttl": 600,
  "classes": "",
  "Github": {
    "user": XXX,
    "token": XXX
  },
  "Bitbucket": {
    "user": "",
    "token": ""
  },
  "Gitlab": {
    "user": "",
    "token": ""
  }
}

To Reproduce
Steps to reproduce the behavior:

  1. Visit https://gis-ops.com/qgis-3-plugin-tutorial-geocoding-with-nominatim-part-2/#recommendations
  2. Observe it stays at the top of the page. It should jump to the destination (e.g. "Recommendations" paragraph)
  3. Visit https://techartaid.com/cheatsheet/
  4. Click on links in Table of Contents. Observe it doesn't follow to the paragraph
  5. Visit the same page on GitHub, observe it works OK: https://github.com/OskarSwierad/game-art-cheatsheet
@nilsnolde
Copy link
Owner

nilsnolde commented Apr 9, 2021

Yeah, this is the fault of Github's weird Markdown rendering (this plugin gets the HTML from Github's /markdown endpoint).. There would probably be a solution one could do in the code, but I wouldn't dig into it.

Github does give you a link you can use, it's just not what you'd expect. Inspect one of your rendered headings:
image

So, the id here is not content-troubleshooting (as you'd expect) but user-content-content-troubleshooting. Try https://techartaid.com/cheatsheet/#user-content-content-troubleshooting and it'll work.

Unfortunately, if you decide to host your markdown files on WP with this plugin, you'll have to edit your markdowns quite a bit (see also #15) and some of the edits will make it unusable with other markdown renderers. Or you'll rely more on raw HTML, which will work in all situations, but who really wants that;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants