diff options
author | zeripath <art27@cantab.net> | 2020-04-24 14:22:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-24 14:22:36 +0100 |
commit | 812cfd0ad9bb85b13ce77f611b3c80dad371d1ef (patch) | |
tree | ff3972334966400b18e079c9f488c01cc840a682 /modules/markup/html.go | |
parent | d3fc9c08c81d8a24ccaaacdb0e6eb0b2619691cf (diff) | |
download | gitea-812cfd0ad9bb85b13ce77f611b3c80dad371d1ef.tar.gz gitea-812cfd0ad9bb85b13ce77f611b3c80dad371d1ef.zip |
Use markdown frontmatter to provide Table of contents, language and frontmatter rendering (#11047)
* Add control for the rendering of the frontmatter
* Add control to include a TOC
* Add control to set language - allows control of ToC header and CJK glyph choice.
Signed-off-by: Andrew Thornton art27@cantab.net
Diffstat (limited to 'modules/markup/html.go')
-rw-r--r-- | modules/markup/html.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/modules/markup/html.go b/modules/markup/html.go index 51d161ecca..294b870d8c 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -351,6 +351,27 @@ func (ctx *postProcessCtx) visitNode(node *html.Node, visitText bool) { visitText = false } else if node.Data == "code" || node.Data == "pre" { return + } else if node.Data == "i" { + for _, attr := range node.Attr { + if attr.Key != "class" { + continue + } + classes := strings.Split(attr.Val, " ") + for i, class := range classes { + if class == "icon" { + classes[0], classes[i] = classes[i], classes[0] + attr.Val = strings.Join(classes, " ") + + // Remove all children of icons + child := node.FirstChild + for child != nil { + node.RemoveChild(child) + child = node.FirstChild + } + break + } + } + } } for n := node.FirstChild; n != nil; n = n.NextSibling { ctx.visitNode(n, visitText) |