package agents import ( "regexp" "strings" ) var ( choiceLine = regexp.MustCompile(`^\s*[-*+]\s+(\([ *]\)|\[[ xX]\])\s+(\S.*?)\s*$`) choiceFence = regexp.MustCompile("^\\s*(```|~~~)") ) type choice struct { text string checkbox bool recommended bool } func parseChoices(markdown string) []choice { choices := []choice{} fence := "" for _, line := range strings.Split(markdown, "\n") { if f := choiceFence.FindStringSubmatch(line); f != nil { switch fence { case "": fence = f[1] case f[1]: fence = "" } continue } if fence != "" { continue } m := choiceLine.FindStringSubmatch(line) if m == nil { continue } choices = append(choices, choice{ text: m[2], checkbox: m[1][0] == '[', recommended: m[1][1] != ' ', }) } return choices }