Skip to content

Commit

Permalink
markup: Add typographic chars from goldmark to toc
Browse files Browse the repository at this point in the history
Fixes #6592
  • Loading branch information
tangiel authored and bep committed Dec 10, 2019
1 parent 0efb00c commit c5f2f58
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions markup/goldmark/toc.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ func (t *tocTransformer) Transform(n *ast.Document, reader text.Reader, pc parse
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
Expand Down
4 changes: 2 additions & 2 deletions markup/goldmark/toc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestToc(t *testing.T) {
content := `
# Header 1
## First h2
## First h2---now with typography!
Some text.
Expand Down Expand Up @@ -61,7 +61,7 @@ And then some.
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&mdash;now with typography!</a>
<ul>
<li><a href="#h3">H3</a></li>
</ul>
Expand Down

0 comments on commit c5f2f58

Please sign in to comment.