Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit ddd3af3

Browse files
authored
Merge pull request #429 from M4FFS/fixbolditalics
Add support for bold italics text
2 parents 56b2dc0 + 75a0efe commit ddd3af3

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

claat/parser/md/html.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ func isItalic(hn *html.Node) bool {
6161
hn.DataAtom == atom.I
6262
}
6363

64+
// This is different to calling isBold and isItalic seperately as we must look
65+
// up an extra level in the tree
66+
func isBoldAndItalic(hn *html.Node) bool {
67+
if hn.Parent == nil || hn.Parent.Parent == nil {
68+
return false
69+
}
70+
if hn.Type == html.TextNode {
71+
hn = hn.Parent
72+
}
73+
return (isItalic(hn) && isBold(hn.Parent)) || (isItalic(hn.Parent) && isBold(hn))
74+
75+
}
76+
6477
func isConsole(hn *html.Node) bool {
6578
if hn.Type == html.TextNode {
6679
hn = hn.Parent

claat/parser/md/parse.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,11 @@ func link(ds *docState) types.Node {
849849
func text(ds *docState) types.Node {
850850
bold := isBold(ds.cur)
851851
italic := isItalic(ds.cur)
852+
// We must call this to look up an extra level in the node tree to obtain both styles
853+
if isBoldAndItalic(ds.cur) {
854+
bold = true
855+
italic = true
856+
}
852857
code := isCode(ds.cur) || isConsole(ds.cur)
853858

854859
// TODO: verify whether this actually does anything

0 commit comments

Comments
 (0)