In-Document Links don't work like on github, elsewhere

Rick's Avatar

Rick

08 Jun, 2017 03:03 AM

I currently have in-document links in my TOC-ish area that look like

## <a name="0">Contents</a> 
- [Special Keys](#special) 
- [Hstore Queries](#hstore) 
- [Errors](#errors) 
    - [Errors Codes](#error_codes) 
    - [Errors Object](#error_object) 
- [Routes](#routes) 

    - [access](#endpoint-access)
        - [get : /api/v1/access/flos/:role_type](#route-get/api/v1/access/flos/:role_type)

The Routes link and the access link successfully jump later down in the document to these two:

## <a name="routes">Routes</a> 

### <a name="endpoint-access">access</a>

but the other ones (of which there are many, sub-items under each route) don't link properly. When I hover over them, they say "jump to ____" like you would expect, but clicking them doesn't actually jump to the headings they are meant to:

##### <a name="route-get/api/v1/access/flos/:role_type"></a>GET | /api/v1/access/flos/:role_type ([top](#0))

This works on github perfectly fine, although I tried grip and kramdown (with not much in terms of playing around with options) and I couldn't get it working. I also tried every configuration of settings possible in marked to see if it would fix the issue, but nothing did. Is this a bug, or is this something a different processor should be used for? And if so, suggestions? Thanks.

  1. 1 Posted by Rick on 08 Jun, 2017 04:02 AM

    Rick's Avatar

    By the way - if I use kramdown -i GFM as a custom processor, the outputted HTML file doesn't have this issue, but the marked preview does.

  2. Support Staff 2 Posted by Brett on 08 Jun, 2017 02:06 PM

    Brett's Avatar

    Marked does some DOM manipulation in the preview window to ensure that ids match up in a way that it can work with for its own table of contents generation, block folding, etc. The <a name> properties you're using are breaking it because it reads the content of the tag as part of the headline. In general, anchors should use <a id> instead of <a name>, and it would be beneficial to put them on a line before the headline instead of within it. That said, I haven't tested extensively with your format, so at this point I'm just offering my first assessment.

  3. 3 Posted by Rick on 08 Jun, 2017 02:30 PM

    Rick's Avatar

    Thanks, Brett. I know the formattng is unorthodox - its from a doc generator that I didnt build (but I have access to), so I may just try to make these links more like something you would see in a typical markdown doc.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • Screen_Shot_2017-06-07_at_7.51.14_PM.png 445 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac