package liturgy import ( "fmt" "regexp" "strings" ) // citationRe captures a scripture reference in a trailing "(...)" of a section // heading, e.g. "Ewangelia (J 20, 1. 11-18)" -> "J 20, 1. 11-18". var citationRe = regexp.MustCompile(`\((.+)\)\s*$`) // ExtractCitation returns the scripture reference carried in a section // heading's trailing parentheses, or an error when the heading has none. func ExtractCitation(heading string) (string, error) { m := citationRe.FindStringSubmatch(heading) if m == nil { return "", fmt.Errorf("no reference found in heading: %q", heading) } return strings.TrimSpace(m[1]), nil }