No internet connection
  1. Home
  2. Ideas

Headers don't have IDs?

By Liam Perez @liam0014
    2022-01-14 19:00:35.737Z

    Hi

    It doesn't look like the markdown headers like the below have default IDs assigned to them, meaning I cannot create a contents within a page or link to specific sections of a page.
    It also doesn't look as if the markdown used in talkyard supports setting custom header IDs

    header

    Details on the markdown that I was hoping to use in an article:
    https://www.markdownguide.org/extended-syntax/#linking-to-heading-ids

    Do let me know if I'm missing something and thanks for taking the time to review my post.

    • 3 replies
    1. Currently none of that works.

      I found: https://www.npmjs.com/package/markdown-it-anchor — how does it compare with what you're looking for? (To me it seems like it does what you want, but maybe I'd better ask anyway.)

      And also: https://www.npmjs.com/package/markdown-it-attrs — for custom header IDs: # Some Header { #custom-id }.

      These things (i.e. auto generated headers, and custom IDs) seems like good to have enabled by default, in Ty. After all, GitHub Pages, Docusaurus (which I'm starting to like :- )), Ghost, Hugo all support this (looking at e.g.: https://www.markdownguide.org/tools/hugo/ and https://docusaurus.io/docs/markdown-features/headings#explicit-ids)

      For now, this: <h2 id="abcd">Header with ID abcd</h2> should be a workaround:

      Header with ID abcd

      And a link to the header: <a href="#abcd">the link</a>

      the link

      1. LLiam Perez @liam0014
          2022-01-20 09:06:37.279Z

          The last part works how I need it, so this is great. I didn't know or consider typing in the HTML directly could get what I wanted.
          Thank you :D

          1. Ok :- )   B.t.w. Talkyard uses CommonMark which supports writing HTML in a Markdown document (like you're doing now, with the links), ...

            ... and to some extent supports writing Markdown inside HTML, look:
            <b>*html_bold_markdown_italcis*</b> renders to: html_bold_markdown_italcis. But usually that just makes me confused, and I try to not place Markdown in HTML like that (e.g. I think line breaks can make the CommonMark parser disagree with you about what's HTML and what's Markdown).

            Anyway, I marked this topic Plan-to-do (i.e. auto generated IDs and { #custom-id-shorthand } — then [Heading IDs](#heading-ids) ToC links should just work).

        • Progress
          with doing this idea
        • @KajMagnus marked this topic as Planned 2022-01-15 10:46:07.867Z.