Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Oct 28, 2014
Merged

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

merged 1 commit into from Oct 28, 2014

Conversation

halostatue
Copy link
Contributor

- 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)
@halostatue
Copy link
Contributor Author

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.

@dmitshur
Copy link
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.

@dmitshur
Copy link
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 added a commit that referenced this pull request Oct 28, 2014
Add a flag to turn on header ID generation.
@rtfb rtfb merged commit 7c8f3c1 into russross:master Oct 28, 2014
@rtfb
Copy link
Collaborator

rtfb commented Oct 28, 2014

Thanks, @halostatue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TOC header ids
3 participants