@@ -48,12 +48,13 @@ type MarkdownElement struct {
4848
4949// TextStyle represents text formatting
5050type TextStyle struct {
51- Bold bool
52- Italic bool
53- Code bool
54- Link string
55- Start int64
56- End int64
51+ Bold bool
52+ Italic bool
53+ Strikethrough bool
54+ Code bool
55+ Link string
56+ Start int64
57+ End int64
5758}
5859
5960// ParagraphStyle represents paragraph-level formatting
@@ -423,17 +424,18 @@ func parseInlineSegment(text string) (string, []TextStyle) {
423424 }
424425 }
425426
426- if marker , bold , italic , ok := inlineMarkerAt (text , i ); ok {
427+ if marker , bold , italic , strikethrough , ok := inlineMarkerAt (text , i ); ok {
427428 searchFrom := i + len (marker )
428429 if end := findClosingInlineMarker (text , searchFrom , marker ); end >= 0 && end > searchFrom {
429430 content , nestedStyles := parseInlineSegment (text [searchFrom :end ])
430431 start := utf16Len (stripped .String ())
431432 stripped .WriteString (content )
432433 styles = append (styles , TextStyle {
433- Start : start ,
434- End : start + utf16Len (content ),
435- Bold : bold ,
436- Italic : italic ,
434+ Start : start ,
435+ End : start + utf16Len (content ),
436+ Bold : bold ,
437+ Italic : italic ,
438+ Strikethrough : strikethrough ,
437439 })
438440 styles = appendShiftedStyles (styles , nestedStyles , start )
439441 i = end + len (marker )
@@ -501,24 +503,41 @@ func appendShiftedStyles(styles []TextStyle, nested []TextStyle, offset int64) [
501503 return styles
502504}
503505
504- func inlineMarkerAt (text string , i int ) (marker string , bold bool , italic bool , ok bool ) {
505- for _ , candidate := range []string {"***" , "___" , "**" , "__" , "*" , "_" } {
506+ func inlineMarkerAt (text string , i int ) (marker string , bold bool , italic bool , strikethrough bool , ok bool ) {
507+ for _ , candidate := range []string {"***" , "___" , "**" , "__" , "~~" , " *" , "_" } {
506508 if ! strings .HasPrefix (text [i :], candidate ) {
507509 continue
508510 }
509511 if candidate [0 ] == '_' && ! isUnderscoreOpeningDelimiter (text , i , len (candidate )) {
510- return "" , false , false , false
512+ return "" , false , false , false , false
513+ }
514+ if candidate == "~~" {
515+ if i > 0 && text [i - 1 ] == '~' {
516+ return "" , false , false , false , false
517+ }
518+ if tildeRunLenAt (text , i ) != len (candidate ) {
519+ return "" , false , false , false , false
520+ }
521+ return candidate , false , false , true , true
511522 }
512523 switch len (candidate ) {
513524 case 3 :
514- return candidate , true , true , true
525+ return candidate , true , true , false , true
515526 case 2 :
516- return candidate , true , false , true
527+ return candidate , true , false , false , true
517528 default :
518- return candidate , false , true , true
529+ return candidate , false , true , false , true
519530 }
520531 }
521- return "" , false , false , false
532+ return "" , false , false , false , false
533+ }
534+
535+ func tildeRunLenAt (text string , i int ) int {
536+ runEnd := i
537+ for runEnd < len (text ) && text [runEnd ] == '~' {
538+ runEnd ++
539+ }
540+ return runEnd - i
522541}
523542
524543func findClosingInlineMarker (text string , searchFrom int , marker string ) int {
@@ -553,6 +572,9 @@ func closingInlineMarkerInRun(text string, searchFrom int, i int, marker string)
553572 if runLen < markerLen {
554573 return 0 , runEnd , false
555574 }
575+ if marker == "~~" {
576+ return i , runEnd , runLen == markerLen
577+ }
556578
557579 if markerLen == 1 {
558580 if runLen == 1 {
0 commit comments