refactor(exporters): replace deprecated strings.Title with cases.Title

The `strings.Title` function is deprecated because it does not handle Unicode punctuation correctly.

This change replaces its usage in the DOCX, HTML, and Markdown exporters with the recommended `golang.org/x/text/cases` package. This ensures more robust and accurate title-casing for item headings.
This commit is contained in:
2025-11-06 03:55:07 +01:00
parent 59f2de9d22
commit 6317ce268b
5 changed files with 18 additions and 4 deletions

View File

@ -11,6 +11,8 @@ import (
"github.com/kjanat/articulate-parser/internal/interfaces"
"github.com/kjanat/articulate-parser/internal/models"
"github.com/kjanat/articulate-parser/internal/services"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
// DocxExporter implements the Exporter interface for DOCX format.
@ -119,7 +121,8 @@ func (e *DocxExporter) exportItem(doc *docx.Docx, item *models.Item) {
// Add item type as heading
if item.Type != "" {
itemPara := doc.AddParagraph()
itemPara.AddText(strings.Title(item.Type)).Size("24").Bold()
caser := cases.Title(language.English)
itemPara.AddText(caser.String(item.Type)).Size("24").Bold()
}
// Add sub-items