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 new TableOfContents Page variable (Markdown only) #173
Conversation
Added TableOfContents field to hugolib.Page struct. New function getTableOfContents is used in convertMarkdown to set the TableOfContents field. Added new test file hugolib/page_toc_test.go with a simple test of the new functionality.
My only concern with the patch as it stands is that the generated TOC stored in the |
I think best thing to do is parse the output and place it in another variable. Does that make sense? I'll try to spend some time digging into this and understand it better. Steve Francia
|
Yes, that's definitely one possibility, although it'd certainly be a bit more fragile if the <nav>
<ul>
<li>
<ul>
<li><a href="#toc_0">Blah blah blah</a></li>
<li><a href="#toc_1">Blah blah blah</a></li>
<li><a href="#toc_2">Blah blah blah</a></li>
</ul></li>
</ul>
</nav> A simple regexp could certainly be written to rip this out of the output and store it in |
Working on merging this in as part of a general refactor. Should merge in shortly. |
Awesome! |
Merged. If you could checkout head and play with it to give some feedback that would be appreciated. |
Awesome, will do! On Tue, Jan 28, 2014 at 11:42 PM, Steve Francia notifications@github.comwrote:
|
So the whole thing works really well, I think. My only gripe is the extra <nav id="TableOfContents">
<ul>
<li>
<ul>
<li><a href="#toc_0">Blah blah blah</a>
<li><a href="#toc_1">Blah blah blah!</a></li>
<li><a href="#toc_2">Blah blah blah</a></li>
<li><a href="#toc_3">Blah blah blah</a></li>
<li><a href="#toc_4">Blah blah blah</a></li>
</ul>
</ul>
</nav> when really I think most people would just want: <nav id="TableOfContents">
<ul>
<li><a href="#toc_0">Blah blah blah</a>
<li><a href="#toc_1">Blah blah blah!</a></li>
<li><a href="#toc_2">Blah blah blah</a></li>
<li><a href="#toc_3">Blah blah blah</a></li>
<li><a href="#toc_4">Blah blah blah</a></li>
</ul>
</nav> See what I mean? |
This is straight from BlackFriday. If you use h1 tags it uses that top UL. For me the ideal would be to use whatever the largest h used as the base rather than always going off h1. Steve Francia
|
I thought that might be the case but didn't check the source. Thanks for adding the feature, it'll definitely come in handy for me. :) |
Actually it appears there's been a change in the way we use blackfriday. Previously, we simply called but now https://github.com/spf13/hugo/blob/master/hugolib/page.go#L587 I am using Markdown tables, which no longer work since we don't pass |
Agree (mostly). We should include all the ones than enable more features, like tables. Care to make a PR? Best, -- From: nwidger nwidger but now markdownRender calls blackfriday.Markdown, but passes different flags/extensions: https://github.com/spf13/hugo/blob/master/hugolib/page.go#L587 I am using Markdown tables, which no longer work since we don't pass EXTENSION_TABLES into blackfriday.Markdown. I think we should change markdownRender to use the same flags/extensions as blackfriday.MarkdownCommon. — |
Sure, I'll try to get to that tonight. |
Add request-id to verbose log messages
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Added TableOfContents field to hugolib.Page struct. New function
getTableOfContents is used in convertMarkdown to set the TableOfContents
field.
Added new test file hugolib/page_toc_test.go with a simple test of the
new functionality.
Pull request for issue #153.