From d3d3b6c5939f58d3c86425651269dd0ad244f483 Mon Sep 17 00:00:00 2001 From: Niklas Fasching Date: Wed, 26 Dec 2018 18:53:31 +0100 Subject: [PATCH] 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... --- org/html_writer.go | 3 +- org/testdata/footnotes.html | 6 ++-- org/testdata/headlines.html | 18 ++++------ org/testdata/misc.html | 72 +++++++++++++------------------------ 4 files changed, 34 insertions(+), 65 deletions(-) diff --git a/org/html_writer.go b/org/html_writer.go index 9cb2014..09e7ff6 100644 --- a/org/html_writer.go +++ b/org/html_writer.go @@ -216,7 +216,8 @@ func (w *HTMLWriter) writeOutline(d *Document) { } func (w *HTMLWriter) writeSection(section *Section) { - w.WriteString("
  • \n") + // NOTE: To satisfy hugo ExtractTOC() check we cannot use `
  • \n` here. Doesn't really matter, just a note. + w.WriteString("
  • ") h := section.Headline title := cleanHeadlineTitleForHTMLAnchorRegexp.ReplaceAllString(w.nodesAsString(h.Title...), "") w.WriteString(fmt.Sprintf("%s\n", h.ID(), title)) diff --git a/org/testdata/footnotes.html b/org/testdata/footnotes.html index 7f86d9b..d449b1c 100644 --- a/org/testdata/footnotes.html +++ b/org/testdata/footnotes.html @@ -1,10 +1,8 @@ diff --git a/org/testdata/headlines.html b/org/testdata/headlines.html index 88d9672..3c491e4 100644 --- a/org/testdata/headlines.html +++ b/org/testdata/headlines.html @@ -1,22 +1,16 @@ diff --git a/org/testdata/misc.html b/org/testdata/misc.html index 2c7de73..9ed0eba 100644 --- a/org/testdata/misc.html +++ b/org/testdata/misc.html @@ -1,84 +1,60 @@