mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-05 16:37:19 -04:00
Support strikethrough elements
This commit is contained in:
+12
@@ -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: "",
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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":
|
||||||
|
|||||||
Reference in New Issue
Block a user