Anchor Links in markdown

Issue #6322 duplicate
Sugendran Ganess created an issue

Markdown links to anchor tags don't get rendered as links, and the inline-html tags don't get rendered as HTML


I expect it to work like this:

Comments (70)

  1. WowWee HK

    This is not a duplicate! it's about creating anchor links in Markdown (which require an HTML tag), it's not about generally supporting an HTML website.

    The issue posted is about fully supporting HTML.

  2. Thomas Neirynck

    I would agree with WowWee.

    Simple anchor tag support would go a long way to help people find info in longer markdown documents, without the need for full-blown html support.

    For example:

    Markdown: <a id="Anchor"></a>

    HTML: <p>&lt;a id="Anchor"&gt;&lt;/a&gt;</p>

  3. Branko Vukelic

    It's a generally accepted notion that you can insert anchors in Markdown simply because there are very widely used implementations that support this, and because there is simply no better way to do it. Sticking to what Python-Markdown guys say is not solving the problem of not being able to insert anchors.

  4. Branko Vukelic

    May I suggest using something like bleach instead of safe mode? It supports tag whitelisting. I'm not sure if bleach can be run on unconverted Markdown (which would be awesome since you can use a short whitelist to trap literal HTML in the source) but it's worth a shot I think. There is also a django app for this.

  5. Ben Madore

    This certainly isn't necessarily a duplicate. Not sure why they felt the need to mark it as such. But, i can't say i have any hope of them ever implementing.

  6. Raf Gemmail

    +1 for supporting anchors. Further more, I encourage targeting github compatibility. When migrating a project from github to bitbucket, having to faf with a broken is a real time waste.

  7. Kota Weaver

    Anchors are absolutely critical for clean README files! This is a must. I don't see what has kept it from being added in after 2.5 years.

  8. Branko Vukelic

    bitbucket apparently doesn't have any passionate developers.

    That's just not fair. They might be passionate about not having anchors, too.

  9. Branko Vukelic

    It has to be mentioned that insertion of HTML (and thus also anchors) is a documented feature.

    For any markup that is not covered by Markdown’s syntax, you simply use HTML itself. There’s no need to preface it or delimit it to indicate that you’re switching from Markdown to HTML; you just use the tags.

    and further below:

    If you want, you can even use HTML tags instead of Markdown formatting; e.g. if you’d prefer to use HTML <a> or <img> tags instead of Markdown’s link or image syntax, go right ahead.

  10. Centrify PS Team

    Running in the same issue here and opted to switch to Creole in the hope anchors would be supported. But they are not either. Also the macro <<TableOfContents()>> which is available in Creole and would simplify my life for creating easy to read WiKi pages seems not better supported and result in being completely ignored. Will go with the scroll-down-a-lot method for now but I am disappointed in not having so basic feature than anchors supported.

  11. Xavier Subira

    Ain't Headings good enough for your purposes? Are your really sure you need anchors for browsing inbetween sections (divided by headings) ?

  12. Branko Vukelic

    One example use case:

    For more information, please see [Other section](#other-section).
    ## <a id="other-section">Other section</a>

    For this specific purpose, auto-generating the anchors would also work, but then it would be harder to predict the ID.

  13. Branko Vukelic

    Come to think of it this may be a good solution to avoid inserting HTML altogether:

    For more information, please see [Other section](#Other section) <-- reference verbatim

    The processor could detect when target URL is a fragment identifier only, and convert it to appropriate ID the same way it does the anchors for the headings.

    EDIT: This still won't take care of documents that are being migrated from other services where anchors are supported.

  14. Centrify PS Team

    Except that this doesn't work. The <a> tag is not parsed and appears as your header. They claim to support Markdown and are prompt to reference daringfireball but still as long as the HTML is not parsed on Bitbucket side it would be inefficient.

  15. João Figueiredo


    Shame they don't do it 'a la github'.

    Still, it works if you follow this syntax, as seen here.

    For more information, please see [this section](#markdown-header-thatsection)
  16. Centrify PS Team

    @joaonvfigueiredo this is awesome, thanks for sharing! Note that if you use spaces in your header then replace them with - and use lower case.

    For more information, please see [this section](#markdown-header-that-section)
    ## That section
  17. M. Emre TÜRE

    I'd really appreciate a universal solution for anchors that will be rendered in the same way in all markdown editors and viewers. markdown-header- prefix seems bitbucket specific. The example of @brankovukelic is much better. name attribute can also be used instead of id.

  18. Zhuohuan LI


    I need anchor too.

    the solution for me is to put a [TOC] in my wiki, then I could get a link with anchor.

    not clean, but usable.

    hope bitbucket could support anchor like github.

  19. Danilo Vaz

    Ashamed that they have not yet implemented it. The Github makes this a long time and write documentation for the projects on Github is a thousand times better than bitbucket.

  20. A K

    +1 really need anchor support. The method proposed by João Figueiredo

    1) does not work in languages ​​other than English. Аn example of the generated ID:


    2) specific for this service only

  21. Aaron Scott-Boddendijk

    I'm currently glad that most of my organisations projects are in Gitlab.

    Amazed Bitbucket hasn't managed to respond positively on this in three years - almost every other application of markdown I've encountered has a way of embedding anchors to assist with navigation within pages.

  22. Patrick Connolly

    Wow. I can't help but think that bitbucket developers are not even using their own platform. Anchors are useful for linked references to notes in bottom of documents. Each note cannot be given a header, just to try to get an anchor.

    Please consider adding this and removing whatever barrier seems to be making this so hard to implement (ie. package perhaps maintained by dogmatic maintainer)

  23. Mathias Kools

    +1 Support for anchors. I like to mirror documentation repos here on bitbucket along with github. I will still have ugly floating <a> anchor tags in my headings if I use the markdown-header solution.

  24. Giovanni Pires da Silva

    Damn... this issue is open since 2013! If they haven't done anything yet, they probably won't. I'll stop watching this. If somehow somebody actually fix this, please, I'd be glad to know. Thanks.

  25. Petr Studený

    Hey, pls support this. I'd like to use the syntax [This is Header][]. This way the MD parser can create the cross-reference using the same function as id of the link.

  26. Benjamin Dobell

    @tonyarcher Ah, no. This issue is marked as a duplicate of #3538, not #6930, and for good reason too. #3538 is specifically with regards to safe HTML, #6930 is incredibly vague.

    On the other hand, people keep commenting here and up-voting this issue not because they don't know about the other issues, but because they don't care about all HTML support. This issue is specifically about anchor support, in particular it's required to create an index of same page links. Most users simply don't care about supporting the entire HTML spec - in fact, I think that sounds like a terrible idea.

  27. Tony Archer

    @bechols I agree with you, but as you can see this issue is flagged duplicate, and therefore isn't being looked at by anyone with any power to do anything about anything. If you can find the thread that is open for a specific issue, please let me know. (I have no control over this ticket's state)

  28. Stephen Ingram

    Can we at least get the same support as github markdown for this, where headings in the document generate anchors?

  29. Merlin Patterson

    It's little things like this that make GitHub a lot better. I don't see any good reason as to why Bitbucket would not want to mirror what GitHub does. The more features y'all mirror from GitHub, the more likely you are to convert people.

    Also, this seems like a simple change. Couldn't you just do something like this?

    makeAnchor = line => `<a href="${line.replace('# ', '').replace(/\s/g, '-').toLowerCase()}">${line}</a>`

    That's simplified (missing checks for odd characters and other headings) but I don't see why it would be much more complicated than that.

  30. Stephen Ingram

    @stmswitcher As numerous others have pointed out this has been incorrectly flagged as a duplicate, GitHub style support would resolve this issue and it does not require partial HTML support. CC @mafrauen

  31. Alastair Wilkes staff
    • edited description
    • changed status to open

    I think this is actually a duplicate of #8276.

    Note: we don't actively review closed issues, so if you think a ticket has been closed prematurely then please open a new issue so we can revisit.

  32. Log in to comment