Fix table of contents for hugo
Hugo has some hardcoded checks that have to be fulfilled in its Table of Contents extraction workflow (helpers/content ExtractTOC). It's easier this way...
This commit is contained in:
parent
940b1c7125
commit
d3d3b6c593
4 changed files with 34 additions and 65 deletions
|
@ -216,7 +216,8 @@ func (w *HTMLWriter) writeOutline(d *Document) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *HTMLWriter) writeSection(section *Section) {
|
func (w *HTMLWriter) writeSection(section *Section) {
|
||||||
w.WriteString("<li>\n")
|
// NOTE: To satisfy hugo ExtractTOC() check we cannot use `<li>\n` here. Doesn't really matter, just a note.
|
||||||
|
w.WriteString("<li>")
|
||||||
h := section.Headline
|
h := section.Headline
|
||||||
title := cleanHeadlineTitleForHTMLAnchorRegexp.ReplaceAllString(w.nodesAsString(h.Title...), "")
|
title := cleanHeadlineTitleForHTMLAnchorRegexp.ReplaceAllString(w.nodesAsString(h.Title...), "")
|
||||||
w.WriteString(fmt.Sprintf("<a href=\"#%s\">%s</a>\n", h.ID(), title))
|
w.WriteString(fmt.Sprintf("<a href=\"#%s\">%s</a>\n", h.ID(), title))
|
||||||
|
|
6
org/testdata/footnotes.html
vendored
6
org/testdata/footnotes.html
vendored
|
@ -1,10 +1,8 @@
|
||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li><a href="#headline-1">Using some footnotes</a>
|
||||||
<a href="#headline-1">Using some footnotes</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-2">Footnotes</a>
|
||||||
<a href="#headline-2">Footnotes</a>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
18
org/testdata/headlines.html
vendored
18
org/testdata/headlines.html
vendored
|
@ -1,22 +1,16 @@
|
||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li><a href="#headline-1">Simple Headline <code class="statistic">[1/2]</code></a>
|
||||||
<a href="#headline-1">Simple Headline <code class="statistic">[1/2]</code></a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-2">Headline with todo status & priority</a>
|
||||||
<a href="#headline-2">Headline with todo status & priority</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#this-will-be-the-id-of-the-headline">Headline with TODO status</a>
|
||||||
<a href="#this-will-be-the-id-of-the-headline">Headline with TODO status</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-4">Headline with tags & priority</a>
|
||||||
<a href="#headline-4">Headline with tags & priority</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-5">headline with custom status</a>
|
||||||
<a href="#headline-5">headline with custom status</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-6">excluded headline</a>
|
||||||
<a href="#headline-6">excluded headline</a>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
72
org/testdata/misc.html
vendored
72
org/testdata/misc.html
vendored
|
@ -1,84 +1,60 @@
|
||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li><a href="#headline-1">issues from goorgeous (free test cases, yay!)</a>
|
||||||
<a href="#headline-1">issues from goorgeous (free test cases, yay!)</a>
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li><a href="#headline-2">#19: Support #+HTML</a>
|
||||||
<a href="#headline-2">#19: Support #+HTML</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-3">#29: Support verse block</a>
|
||||||
<a href="#headline-3">#29: Support verse block</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-4">#31: Support #+INCLUDE</a>
|
||||||
<a href="#headline-4">#31: Support #+INCLUDE</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-5">#33: Wrong output when mixing html with Org mode</a>
|
||||||
<a href="#headline-5">#33: Wrong output when mixing html with Org mode</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-6">#46: Support for symbols like ndash and mdash</a>
|
||||||
<a href="#headline-6">#46: Support for symbols like ndash and mdash</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-7">#47: Consecutive <code>code</code> wrapped text gets joined</a>
|
||||||
<a href="#headline-7">#47: Consecutive <code>code</code> wrapped text gets joined</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-8">#50: LineBreaks in lists are preserved</a>
|
||||||
<a href="#headline-8">#50: LineBreaks in lists are preserved</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-9">#68: Quote block with inline markup</a>
|
||||||
<a href="#headline-9">#68: Quote block with inline markup</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-10">#72: Support for #+ATTR_HTML</a>
|
||||||
<a href="#headline-10">#72: Support for #+ATTR_HTML</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-11">#75: Not parsing nested lists correctly</a>
|
||||||
<a href="#headline-11">#75: Not parsing nested lists correctly</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-12">#77: Recognize <code class="verbatim">code</code>— as code plus dash</a>
|
||||||
<a href="#headline-12">#77: Recognize <code class="verbatim">code</code>— as code plus dash</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-13">#78: Emphasis at beginning of line</a>
|
||||||
<a href="#headline-13">#78: Emphasis at beginning of line</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-14">#82: Crash on empty headline</a>
|
||||||
<a href="#headline-14">#82: Crash on empty headline</a>
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li><a href="#headline-15"></a>
|
||||||
<a href="#headline-15"></a>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-16">#84: Paragraphs that are not followed by an empty line are not parsed correctly</a>
|
||||||
<a href="#headline-16">#84: Paragraphs that are not followed by an empty line are not parsed correctly</a>
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li><a href="#headline-17">Foo</a>
|
||||||
<a href="#headline-17">Foo</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-18">Bar</a>
|
||||||
<a href="#headline-18">Bar</a>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-19">#86: Multiple hyphens not converted to dashes</a>
|
||||||
<a href="#headline-19">#86: Multiple hyphens not converted to dashes</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-20">#87: Markup in footnotes is rendered literally</a>
|
||||||
<a href="#headline-20">#87: Markup in footnotes is rendered literally</a>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-21">issues (wrongly) filed with hugo</a>
|
||||||
<a href="#headline-21">issues (wrongly) filed with hugo</a>
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li><a href="#headline-22">#3874 exporting images in org mode</a>
|
||||||
<a href="#headline-22">#3874 exporting images in org mode</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-23">#4006 source code blocks in org not rendered correctly</a>
|
||||||
<a href="#headline-23">#4006 source code blocks in org not rendered correctly</a>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><a href="#headline-24">Footnotes</a>
|
||||||
<a href="#headline-24">Footnotes</a>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue