Anchor generation doesn't allow for multiple headers with same text

If I have a page with multiple sections with similar subheadings, I can’t link to these subheadings individually unless I give them different heading text. Example:

I want a page heading structure similar to this:

Accounts

  • Definition
  • Data Model
  • Endpoints
    Transactions
  • Definition
  • Data Model
  • Endpoints

I normally would be able to link to the subheadings directly by doing something like “/mysite/mypage#definition”, but the problem is I have a Definition subheading in two places on the page and the middleman build creates two anchor tags with the id “definition” so it always goes to the first one on the page. As such I can never direct a customer directly to documentation on Transaction Definitions. I would expect an anchor tag generated to take into account the nested nature or at least to be able to determine if there are multiple headings on a page with the same header text and generate something like “” and “”. This seems like a design bug to me as I could easily generate my own HTML to do exactly what I’m describing but it would be overwritten every time I build my site using middleman.

Am I missing something? Is there a way to do what I want or is this a bug that needs to be fixed?

Been over a year and no response. Not a good sign.

Maybe the reason is I dont think this sounds like a Middleman issue. I do not believe Middleman creates its own IDs automatically.

Are you using markdown to render the pages? And the Table of content?
If so then you can create your own templates for this.

Post more example code.