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

Docs: Give headers ids for easy linking #360

Merged
merged 1 commit into from
Sep 23, 2013

Conversation

zpao
Copy link
Member

@zpao zpao commented Sep 19, 2013

This gives markdown headers an id so that we can link directly to
sections of our docs. This is better than the alternative of adding them
all ourselves.

I think this is better than what @SanderSpies added in #359 (sorry!) and is more maintainable. I tried switching to a different markdown parser (maraku) but it struggled with some of the things we do and I think this is pretty close to what maraku does. I'm actually going to take a look at what it does and maybe get inspired... with fewer additional dependencies.

Don't merge me yet.

@sophiebits
Copy link
Contributor

Discount (a Markdown implementation in C) keeps alnum and _:-. and replaces all other characters with ., prepending an L if the first char isn't a letter:

https://github.com/Orc/discount/blob/master/mkdio.c#L212-L241


class Redcarpet::Render::HTML
def header(title, level)
clean_title = Sanitize.clean(title).downcase.gsub(/\s+/, "-")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you indent it

clean_title = Sanitize.clean(title)
  .downcase
  .gsub(/\s+/, "-")
  .gsub(/[^A-Za-z0-9\-_.]/, "")

@vjeux
Copy link
Contributor

vjeux commented Sep 21, 2013

Accepted :)

This gives markdown headers an id so that we can link directly to
sections of our docs. This is better than the alternative of adding them
all ourselves.
@zpao zpao merged commit d27746e into facebook:master Sep 23, 2013
@zpao zpao deleted the docs-header-permalinks branch September 23, 2013 17:31
bvaughn pushed a commit to bvaughn/react that referenced this pull request Aug 13, 2019
* feat: match HOC display names during search

* chore: update tests for new search logic
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.

3 participants