This commit is contained in:
Tomas Dvorak
2026-02-22 15:41:27 +01:00
parent 0b88627e54
commit 409acd2e08
84 changed files with 65382 additions and 27475 deletions
+15 -1
View File
@@ -13,6 +13,20 @@ import (
"github.com/yuin/goldmark/renderer/html"
)
// titleCase converts a string to title case (first letter of each word capitalized)
func titleCase(s string) string {
if s == "" {
return s
}
words := strings.Fields(s)
for i, word := range words {
if len(word) > 0 {
words[i] = strings.ToUpper(word[:1]) + strings.ToLower(word[1:])
}
}
return strings.Join(words, " ")
}
// Document represents a scraped document to be formatted as markdown
type Document struct {
ID string `json:"id"`
@@ -66,7 +80,7 @@ func (f *Formatter) ToMarkdown(doc *Document) string {
if doc.Metadata != nil {
for key, value := range doc.Metadata {
if strValue := fmt.Sprintf("%v", value); strValue != "" && strValue != "<nil>" {
buf.WriteString(fmt.Sprintf("| **%s** | %s |\n", strings.Title(key), strValue))
buf.WriteString(fmt.Sprintf("| **%s** | %s |\n", titleCase(key), strValue))
}
}
}