Support strikethrough elements

This commit is contained in:
Christian Muehlhaeuser
2019-12-13 03:00:45 +01:00
parent 6f20136abc
commit 0a3ba0ae35
3 changed files with 16 additions and 1 deletions
+12
View File
@@ -149,6 +149,18 @@ func (tr *TermRenderer) NewElement(node ast.Node, source []byte) Element {
}, },
} }
case astext.KindStrikethrough:
n := node.(*astext.Strikethrough)
s := string(n.Text(source))
style := ctx.style[Strikethrough]
return Element{
Renderer: &BaseElement{
Token: ctx.SanitizeHTML(s, false),
Style: style,
},
}
case ast.KindThematicBreak: case ast.KindThematicBreak:
return Element{ return Element{
Entering: "", Entering: "",
+1 -1
View File
@@ -211,7 +211,7 @@ func isChild(node ast.Node) bool {
// These types are already rendered by their parent // These types are already rendered by their parent
switch node.Parent().Kind() { switch node.Parent().Kind() {
case ast.KindLink, ast.KindImage, ast.KindEmphasis, ast.KindBlockquote, astext.KindTableCell: case ast.KindLink, ast.KindImage, ast.KindEmphasis, astext.KindStrikethrough, ast.KindBlockquote, astext.KindTableCell:
return true return true
default: default:
return false return false
+3
View File
@@ -25,6 +25,7 @@ const (
// Text elements // Text elements
Text Text
Strikethrough
Emph Emph
Strong Strong
HorizontalRule HorizontalRule
@@ -275,6 +276,8 @@ func keyToType(key string) (StyleType, error) {
return H6, nil return H6, nil
case "hr": case "hr":
return HorizontalRule, nil return HorizontalRule, nil
case "strikethrough":
return Strikethrough, nil
case "emph": case "emph":
return Emph, nil return Emph, nil
case "strong": case "strong":