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

Commit 5d9add3

Browse files
author
Matthew Williams
committed
Add support for bold italics text
1 parent 3d93242 commit 5d9add3

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

claat/parser/md/html.go

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

64+
func isBoldAndItalic(hn *html.Node) bool {
65+
if hn.Parent == nil || hn.Parent.Parent == nil {
66+
return false
67+
}
68+
if hn.Type == html.TextNode {
69+
hn = hn.Parent
70+
}
71+
return (isItalic(hn) && isBold(hn.Parent)) || (isItalic(hn.Parent) && isBold(hn))
72+
73+
}
74+
6475
func isConsole(hn *html.Node) bool {
6576
if hn.Type == html.TextNode {
6677
hn = hn.Parent

claat/parser/md/parse.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,10 @@ func link(ds *docState) types.Node {
849849
func text(ds *docState) types.Node {
850850
bold := isBold(ds.cur)
851851
italic := isItalic(ds.cur)
852+
if isBoldAndItalic(ds.cur) {
853+
bold = true
854+
italic = true
855+
}
852856
code := isCode(ds.cur) || isConsole(ds.cur)
853857

854858
// TODO: verify whether this actually does anything

0 commit comments

Comments
 (0)