mirror of
https://github.com/kjanat/articulate-parser.git
synced 2026-08-05 22:04:06 +02:00
fix(lint): resolve golangci-lint failures and modernize string handling
CI's golangci-lint (v2.12.2) job was failing with 14 issues, which blocked
the dependent test job. This addresses all of them:
- goconst: extract repeated string literals into constants
- format aliases ("md", "word", "htm") in the exporter factory
- "section" lesson type shared by markdown and HTML exporters
- default Articulate Rise base URL and host in the parser
- reuse existing itemType* constants in the markdown switch
- staticcheck (QF1012): replace buf.WriteString(fmt.Sprintf(...)) with
fmt.Fprintf(...) in the markdown exporter
Also drop the hardcoded `go: "1.24"` from .golangci.yml so the target Go
version is autodetected from go.mod.
This commit is contained in:
@@ -13,6 +13,11 @@ const (
|
||||
FormatMarkdown = "markdown"
|
||||
FormatDocx = "docx"
|
||||
FormatHTML = "html"
|
||||
|
||||
// Format aliases accepted by CreateExporter.
|
||||
formatAliasMarkdown = "md"
|
||||
formatAliasDocx = "word"
|
||||
formatAliasHTML = "htm"
|
||||
)
|
||||
|
||||
// Factory implements the ExporterFactory interface.
|
||||
@@ -41,11 +46,11 @@ func NewFactory(htmlCleaner *services.HTMLCleaner) interfaces.ExporterFactory {
|
||||
// Format strings are case-insensitive (e.g., "markdown", "DOCX").
|
||||
func (f *Factory) CreateExporter(format string) (interfaces.Exporter, error) {
|
||||
switch strings.ToLower(format) {
|
||||
case FormatMarkdown, "md":
|
||||
case FormatMarkdown, formatAliasMarkdown:
|
||||
return NewMarkdownExporter(f.htmlCleaner), nil
|
||||
case FormatDocx, "word":
|
||||
case FormatDocx, formatAliasDocx:
|
||||
return NewDocxExporter(f.htmlCleaner), nil
|
||||
case FormatHTML, "htm":
|
||||
case FormatHTML, formatAliasHTML:
|
||||
return NewHTMLExporter(f.htmlCleaner), nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported export format: %s", format)
|
||||
@@ -55,5 +60,9 @@ func (f *Factory) CreateExporter(format string) (interfaces.Exporter, error) {
|
||||
// SupportedFormats returns a list of all supported export formats,
|
||||
// including both primary format names and their aliases.
|
||||
func (f *Factory) SupportedFormats() []string {
|
||||
return []string{FormatMarkdown, "md", FormatDocx, "word", FormatHTML, "htm"}
|
||||
return []string{
|
||||
FormatMarkdown, formatAliasMarkdown,
|
||||
FormatDocx, formatAliasDocx,
|
||||
FormatHTML, formatAliasHTML,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user