-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Support Markdown Render Hooks for Headers #6713
Comments
The proposed
With this at hand, a header such as ## Getting Started Could be converted to a header with the paragraph icon link using something along the lines of <h{{ .Level }}>{{ .Text }}</h{{ .Level }}><a href="#{{ .Anchor }}">¶</a> |
I like this proposal. Just a minor nitpick .. to call it |
I concur - the CommonMark spec also talks about headings, so |
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
(keeping this from stale-ing) This still would be very useful for me. It's a common feature on blogs, it lets me cross-link within my article, and it allows me to share more helpful links to other people. |
Adds a custom heading renderer like the current custom link and image renderers. TODO - [ ] run locally and add tests - [ ] cleanup - should this be called "render_hooks" instead of "render_link"? - [ ] [now that there are three use cases, should I try to deduplicate](https://camlittle.com/posts/when-to-add-abstractions/) ? Resolves gohugoio#6713
I am just about to fiddle this into the theme I'm using – before I do, I'd like to confirm: Does it look like this will make it into an upcoming release? |
I have initially been a little hesitant about this feature; not the things It tries to solve (I recently found one more thing that this feature would help with), but I have been hoping to get to a state this could be solved in a ... more elegant way (I have talked about this elsewhere). Image and link hooks was kind of obvious -- we really needed those right away, and they have proved it's usefulness. But since that "elegant way" seem to take some time, I'll say that now is the time to also add render hooks for titles. So yes, just let me know when this is ready and I'll have a look and eventually merge it. |
I think this is close to ready:
|
This commit also * Renames previous types to be non-specific. (e.g. hookedRenderer rather than linkRenderer) Resolves #6713
This commit also * Renames previous types to be non-specific. (e.g. hookedRenderer rather than linkRenderer) Resolves gohugoio#6713
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. |
A useful feature provided by many web applications is the ability to conveniently get a link referencing a specific header in the page. People can then bookmark or share the link in order to reference an individual section. Consider e.g. the Effective Go page and try hovering the mouse above any of the headers with a blue background: the shown paragraph symbol is a link to the respective header. Copying the address of the link gets you the URL referencing the header.
Right now, automatically adding such anchor links is possible in Hugo by filtering the entire HTML markup of a page, e.g. given a partial
add-header-anchors.html
withOne can use
With the advent of Markdown render hooks, this seems like a hack. Instead, it would be great if the HTML generated for headers could be customised using a hook such as
layouts/_default/_markup/render-header.html
The text was updated successfully, but these errors were encountered: