ref: c5f2f5837fdf6a30c7b28e8368033623b74a30a0
parent: 0efb00c2a86ec3f52000a643f26f54bb2a9dfbd6
author: Daniel Tang <tangd@google.com>
date: Tue Dec 10 07:37:52 EST 2019
markup: Add typographic chars from goldmark to toc Fixes #6592
--- a/markup/goldmark/toc.go
+++ b/markup/goldmark/toc.go
@@ -79,9 +79,8 @@
if found {
header.ID = string(id.([]byte))
}
- case ast.KindText:
- textNode := n.(*ast.Text)
- headingText.Write(textNode.Text(reader.Source()))
+ case ast.KindText, ast.KindString:
+ headingText.Write(n.Text(reader.Source()))
}
return s, nil
--- a/markup/goldmark/toc_test.go
+++ b/markup/goldmark/toc_test.go
@@ -32,7 +32,7 @@
content := `
# Header 1
-## First h2
+## First h2---now with typography!
Some text.
@@ -61,7 +61,7 @@
got := b.(converter.TableOfContentsProvider).TableOfContents().ToHTML(2, 3)
c.Assert(got, qt.Equals, `<nav id="TableOfContents">
<ul>
- <li><a href="#first-h2">First h2</a>
+ <li><a href="#first-h2---now-with-typography">First h2—now with typography!</a>
<ul>
<li><a href="#h3">H3</a></li>
</ul>