From 0a3ba0ae352a9c89426e3473b1d552b357a1bb6f Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Thu, 12 Dec 2019 22:20:08 +0100 Subject: [PATCH] Support strikethrough elements --- elements.go | 12 ++++++++++++ gold.go | 2 +- style.go | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/elements.go b/elements.go index fc70aaf..5601044 100644 --- a/elements.go +++ b/elements.go @@ -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: return Element{ Entering: "", diff --git a/gold.go b/gold.go index 820e3bd..2d5885b 100644 --- a/gold.go +++ b/gold.go @@ -211,7 +211,7 @@ func isChild(node ast.Node) bool { // These types are already rendered by their parent 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 default: return false diff --git a/style.go b/style.go index 089ced0..765795b 100644 --- a/style.go +++ b/style.go @@ -25,6 +25,7 @@ const ( // Text elements Text + Strikethrough Emph Strong HorizontalRule @@ -275,6 +276,8 @@ func keyToType(key string) (StyleType, error) { return H6, nil case "hr": return HorizontalRule, nil + case "strikethrough": + return Strikethrough, nil case "emph": return Emph, nil case "strong":