[Link][section] to other sections doesn't work

Giannis G's Avatar

Giannis G

02 Sep, 2023 02:35 PM

Hello,

I've been using Marked 2 for years to work on individual files and it has always been a superb companion!

I recently realised I can use it to work on multiple interconnected files, creating a personal wiki on my computer. I connect one file to the other via links in the form of [text link](file_name.md)... and this works great.

However, when I try to connect to specific headings of either another or the very same file, the linking doesn't work. I've tried:

Go to [Section 1][section1]...

### Section 1 [section1]
...

... and it doesn't work. (The link appears, but when I click it, I don't "travel" to Section 1.

The only form that works within the same file is this:

<a id="section1"></a>
### Section 1
...
Go to [Section 1](#section1).

Although it's disappointing that the [link text][section-id] form doesn't work, I would be ok using the <a id=...> form if it actually worked to link to specific sections of other files, as in Go to the [Roman](history.md#roman) section.

Unfortunately, it doesn't.

I'm using Multi-Markdown.

TL;DR:

  • Why does this form not work: Go to [Section 1][section1]?
  • How can I link to sections of other files?

Many thanks

  1. Support Staff 1 Posted by Brett on 02 Sep, 2023 07:17 PM

    Brett's Avatar

    Adding an id to a header does not create a link reference, so you always
    need to use the format `[link text](#section)` and not `[link
    text][section]`. If you do that, the sections should be navigable within
    a document.

    Because Marked is not a fully-fledged web browser, it can only respond
    to opening a file, not opening a file and targeting a specific section.
    `[link text](file.md#section)` isn't going to work within Marked, but
    `[link text](file.html#section)` would work in exported documents.

    -Brett

    On 2 Sep 2023, at 9:38, Giannis G wrote:

  2. 2 Posted by Giannis G on 03 Sep, 2023 04:36 PM

    Giannis G's Avatar

    Hi Brett,

    Thank you for your prompt and clarifying response!

    Regarding the first part of your answer, do I explicitly have to use the `<a id=...>` syntax over the target heading and not the `### Heading [heading-id]` one?

    Regarding the second part: this is not something that will be implemented in the future from your end, right?

    Best,
    Giannis

    Sent from my iPhone

  3. Support Staff 3 Posted by Brett on 03 Sep, 2023 06:28 PM

    Brett's Avatar

    Using [id] after a headline generates an ID, which functions the same as manually inserting a name tag with id. So that part is unnecessary.

    And correct, Marked will likely never function as a fully-fledged web browser. Though I’m willing to look into this further if time allows.

    - Brett
    On Sep 3, 2023 at 11:36 AM -0500, Giannis G <[email blocked]>, wrote:

Reply to this discussion

Internal reply

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

Attaching KB article:

»

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