Skip to content
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

Use markdown frontmatter to provide Table of contents, language and frontmatter rendering #11047

Merged
merged 18 commits into from
Apr 24, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
placate unit tests
Signed-off-by: Andrew Thornton <[email protected]>
  • Loading branch information
zeripath committed Apr 12, 2020
commit b87baff0738ce38f74b719c0423c52d9699bdb32
28 changes: 15 additions & 13 deletions modules/markup/markdown/goldmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,21 +228,23 @@ func (r *HTMLRenderer) renderDocument(w util.BufWriter, source []byte, node ast.
log.Info("renderDocument %v", node)
n := node.(*ast.Document)

var err error
if entering {
_, err = w.WriteString("<div")
if val, has := n.AttributeString("lang"); has && err == nil {
_, err = w.WriteString(fmt.Sprintf(` lang=%q`, val))
}
if err == nil {
_, err = w.WriteRune('>')
if val, has := n.AttributeString("lang"); has {
var err error
if entering {
_, err = w.WriteString("<div")
if err == nil {
_, err = w.WriteString(fmt.Sprintf(` lang=%q`, val))
}
if err == nil {
_, err = w.WriteRune('>')
}
} else {
_, err = w.WriteString("</div>")
}
} else {
_, err = w.WriteString("</div>")
}

if err != nil {
return ast.WalkStop, err
if err != nil {
return ast.WalkStop, err
}
}

return ast.WalkContinue, nil
Expand Down