mirror of
https://github.com/kjanat/articulate-parser.git
synced 2026-10-13 01:35:27 +02:00
refactor: extract HTMLCleaner interface and consolidate constants
- Add interfaces.HTMLCleaner interface for better testability - Add CleanAndTrim() method to simplify repeated pattern - Move item/lesson type constants to models/item_types.go - Update all exporters to use interface instead of concrete type - Replace strings.TrimSpace(CleanHTML(...)) with CleanAndTrim()
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package interfaces
|
||||
|
||||
// HTMLCleaner defines the interface for cleaning HTML content.
|
||||
// Implementations convert HTML to plain text, stripping tags and decoding entities.
|
||||
type HTMLCleaner interface {
|
||||
// CleanHTML removes HTML tags and decodes HTML entities from a string.
|
||||
// Returns plain text suitable for non-HTML output formats.
|
||||
CleanHTML(htmlStr string) string
|
||||
|
||||
// CleanAndTrim removes HTML tags, decodes entities, and trims whitespace.
|
||||
// Convenience method combining CleanHTML with strings.TrimSpace.
|
||||
CleanAndTrim(htmlStr string) string
|
||||
}
|
||||
Reference in New Issue
Block a user