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: Remove the findRE TOC example #3188

Closed
whereandy opened this issue Mar 16, 2017 · 7 comments
Closed

docs: Remove the findRE TOC example #3188

whereandy opened this issue Mar 16, 2017 · 7 comments

Comments

@whereandy
Copy link

In the documentation for generating a table of contents using findRE to grab h2's, the <a href="#{{ . | plainify | urlize }}"> will not correctly generate links for heading anchors that have non-alphanumeric characters in them, such as periods. The workaround I came up with was:

{{ . | plainify | htmlUnescape | urlize | replaceRE "([^0-9a-zA-Z\\.\\-\\s])" "" | replaceRE "(\\.)" "-" | replaceRE "(\\-){2,}" "-" }} 

Which replicated the process described in heading anchor generation.

@bep
Copy link
Member

bep commented Mar 20, 2017

If this is in the docs, it should be removed, not be made more complex. Adding replaceRE was maybe a mistake, but please don't add such anti-patterns to the docs.

@bep bep added the Docs label Mar 20, 2017
@bep bep changed the title Example for TOC generation in findRE doco does not account for non-alphanumerics docs: Remove the replaceRE TOC example Mar 20, 2017
@rdwatters
Copy link
Contributor

Remove the replaceRE TOC example

There isn't a replaceRE TOC example in the (new or current) docs. Are you talking about findRE, @bep?

@bep
Copy link
Member

bep commented Mar 20, 2017

I'm not talking about anything. If there isn't a replaceRE TOC example in the docs, then the thread starter must have dreamed it (which I doubt), and then this issue could be closed.

@rdwatters
Copy link
Contributor

rdwatters commented Mar 20, 2017

That would be a very dull dream:

https://gohugo.io/templates/functions/#findre

You framed your response in the example of replaceRE and then said adding that function might have been a mistake. I am only asking if you still think the findRE example in the current docs needs to be removed...

@bep bep changed the title docs: Remove the replaceRE TOC example docs: Remove the findRE TOC example Mar 20, 2017
@bep
Copy link
Member

bep commented Mar 20, 2017

In the documentation for generating a table of contents using findRE to grab h2's...

OK, I have updated the issue title. But the relevant example is in the above.

@rdwatters
Copy link
Contributor

This has been removed from the findRe example in the new docs site:

https://hugodocs.info/functions/findre

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants