Add a flag to turn on header ID generation. #125

Merged
merged 1 commit into from Oct 28, 2014

Projects

None yet

3 participants

@halostatue
Contributor
  • Fixes #51, #101, and #102.
  • Uses the code mentioned by @shurcooL from his Github
    Flavored Markdown parser extension in a comment on #102.
    Since this was mentioned, I assumed that @shurcooL would be OK with
    this being included under the licence provided by blackfriday (there
    is no licence comment on his code).
  • I’ve added it behind another flag, EXTENSION_AUTO_HEADER_IDS, that
    would need to be turned on for it to work. It works with both prefix
    and underline headers.
@halostatue halostatue Add a flag to turn on header ID generation.
- Fixes #51, #101, and #102.
- Uses the [code][gfm] mentioned by @shurcooL from his Github
  Flavored Markdown parser extension in a [comment on #102][comment].
  Since this was mentioned, I assumed that @shurcooL would be OK with
  this being included under the licence provided by blackfriday (there
  is no licence comment on his code).
- I’ve added it behind another flag, EXTENSION_AUTO_HEADER_IDS, that
  would need to be turned on for it to work. It works with both prefix
  and underline headers.

[gfm]: https://github.com/shurcooL/go/blob/3bec0366a85101d116bf88b477e92ea6cdd75e4e/github_flavored_markdown/main.go#L90-L102
[comment]: #102 (comment)
a5e88a3
@halostatue
Contributor

When combined with #124, the automatically generated header ID will be used in the TOC. A manually provided header # header {#someid} will be used in preference to the automatically generated header.

@shurcooL
Collaborator

I assumed that @shurcooL would be OK with this being included under the licence provided by blackfriday

I'm absolutely fine with that if it's helpful, no worries.

I did recently move that functionality out into a separate smaller package, so it's possible to import it without bringing in too many unrelated Go dependencies. See sanitized_anchor_name and shurcooL/go@c801d13.

@shurcooL
Collaborator

The changes look good to me. Nice job adding tests too. It should close all those 3 issues.

But I'm not the best person to review this PR because this optionally (behind a flag) affects the HTML renderer, and I personally only use the blackfriday Markdown parser with my GFM renderer, which already does this functionality by default, so I'll never get a chance to use this.

@rtfb rtfb merged commit 7c8f3c1 into russross:master Oct 28, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details
@rtfb
Collaborator
rtfb commented Oct 28, 2014

Thanks, @halostatue!

@halostatue halostatue deleted the unknown repository branch Nov 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment