change hint handlign to use bold and italic tags instead

This commit is contained in:
2026-01-04 05:09:33 +00:00
parent 34fde8ac27
commit 9b1506623e
+5 -3
View File
@@ -31,7 +31,7 @@ type NoteView struct {
title string // the first line is always # title title string // the first line is always # title
content string // strip the first line from file rest is content content string // strip the first line from file rest is content
rawContent string // full content for editing rawContent string // full content for editing
hints []string //a hint is anything that matches (hint: <text>) in content hints []string //a hint is anything that matches **text** or __text__ in content
// display layer // display layer
err error err error
loading bool loading bool
@@ -219,12 +219,14 @@ func saveContent(path, content string) tea.Cmd {
} }
func extractHints(content string) []string { func extractHints(content string) []string {
re := regexp.MustCompile(`(?s)\(hint:\s*(.*?)\)`) re := regexp.MustCompile(`(?s)\*\*(.*?)\*\*|__(.*?)__`)
matches := re.FindAllStringSubmatch(content, -1) matches := re.FindAllStringSubmatch(content, -1)
hints := make([]string, 0) hints := make([]string, 0)
for _, match := range matches { for _, match := range matches {
if len(match) > 1 { if len(match) > 1 && match[1] != "" {
hints = append(hints, match[1]) hints = append(hints, match[1])
} else if len(match) > 2 && match[2] != "" {
hints = append(hints, match[2])
} }
} }
return hints return hints