mirror of
https://github.com/kjanat/articulate-parser.git
synced 2026-01-16 12:22:08 +01:00
feat: Add HTML export functionality and GitHub workflow
- Implement HTMLExporter with professional styling and embedded CSS
- Add comprehensive test suite for HTML export functionality
- Update factory to support HTML format ('html' and 'htm')
- Add autofix.ci GitHub workflow for code formatting
- Support all content types: text, lists, quizzes, multimedia, etc.
- Include proper HTML escaping for security
- Add benchmark tests for performance validation
This commit is contained in:
@ -70,6 +70,20 @@ func TestFactory_CreateExporter(t *testing.T) {
|
||||
expectedFormat: "docx",
|
||||
shouldError: false,
|
||||
},
|
||||
{
|
||||
name: "html format",
|
||||
format: "html",
|
||||
expectedType: "*exporters.HTMLExporter",
|
||||
expectedFormat: "html",
|
||||
shouldError: false,
|
||||
},
|
||||
{
|
||||
name: "htm format alias",
|
||||
format: "htm",
|
||||
expectedType: "*exporters.HTMLExporter",
|
||||
expectedFormat: "html",
|
||||
shouldError: false,
|
||||
},
|
||||
{
|
||||
name: "unsupported format",
|
||||
format: "pdf",
|
||||
@ -139,6 +153,12 @@ func TestFactory_CreateExporter_CaseInsensitive(t *testing.T) {
|
||||
{"WORD", "docx"},
|
||||
{"Word", "docx"},
|
||||
{"WoRd", "docx"},
|
||||
{"HTML", "html"},
|
||||
{"Html", "html"},
|
||||
{"HtMl", "html"},
|
||||
{"HTM", "html"},
|
||||
{"Htm", "html"},
|
||||
{"HtM", "html"},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
@ -168,7 +188,6 @@ func TestFactory_CreateExporter_ErrorMessages(t *testing.T) {
|
||||
|
||||
testCases := []string{
|
||||
"pdf",
|
||||
"html",
|
||||
"txt",
|
||||
"json",
|
||||
"xml",
|
||||
@ -213,7 +232,7 @@ func TestFactory_GetSupportedFormats(t *testing.T) {
|
||||
t.Fatal("GetSupportedFormats() returned nil")
|
||||
}
|
||||
|
||||
expected := []string{"markdown", "md", "docx", "word"}
|
||||
expected := []string{"markdown", "md", "docx", "word", "html", "htm"}
|
||||
|
||||
// Sort both slices for comparison
|
||||
sort.Strings(formats)
|
||||
@ -321,6 +340,21 @@ func TestFactory_HTMLCleanerPropagation(t *testing.T) {
|
||||
if docxImpl.htmlCleaner == nil {
|
||||
t.Error("HTMLCleaner should be propagated to DocxExporter")
|
||||
}
|
||||
|
||||
// Test with html exporter
|
||||
htmlExporter, err := factory.CreateExporter("html")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create html exporter: %v", err)
|
||||
}
|
||||
|
||||
htmlImpl, ok := htmlExporter.(*HTMLExporter)
|
||||
if !ok {
|
||||
t.Fatal("Failed to cast to HTMLExporter")
|
||||
}
|
||||
|
||||
if htmlImpl.htmlCleaner == nil {
|
||||
t.Error("HTMLCleaner should be propagated to HTMLExporter")
|
||||
}
|
||||
}
|
||||
|
||||
// TestFactory_MultipleExporterCreation tests creating multiple exporters of same type.
|
||||
|
||||
Reference in New Issue
Block a user