Adds DOCX and Markdown export functionality

Introduces a modular exporter pattern supporting DOCX and Markdown formats
by implementing Exporter interfaces and restructuring application logic.

Enhances CI to install UPX for binary compression, excluding recent macOS
binaries due to compatibility issues.

Enables CGO when building binaries for all platforms, addressing potential
cross-platform compatibility concerns.

Bumps version to 0.1.1.
This commit is contained in:
2025-05-25 13:01:58 +02:00
parent 48cad7144f
commit 9de7222ec3
15 changed files with 1096 additions and 600 deletions

View File

@ -0,0 +1,31 @@
// Package interfaces provides the core contracts for the articulate-parser application.
// It defines interfaces for parsing and exporting Articulate Rise courses.
package interfaces
import "github.com/kjanat/articulate-parser/internal/models"
// Exporter defines the interface for exporting courses to different formats.
// Implementations of this interface handle the conversion of course data to
// specific output formats like Markdown or DOCX.
type Exporter interface {
// Export converts a course to the supported format and writes it to the
// specified output path. It returns an error if the export operation fails.
Export(course *models.Course, outputPath string) error
// GetSupportedFormat returns the name of the format this exporter supports.
// This is used to identify which exporter to use for a given format.
GetSupportedFormat() string
}
// ExporterFactory creates exporters for different formats.
// It acts as a factory for creating appropriate Exporter implementations
// based on the requested format.
type ExporterFactory interface {
// CreateExporter instantiates an exporter for the specified format.
// It returns the appropriate exporter or an error if the format is not supported.
CreateExporter(format string) (Exporter, error)
// GetSupportedFormats returns a list of all export formats supported by this factory.
// This is used to inform users of available export options.
GetSupportedFormats() []string
}

View File

@ -0,0 +1,20 @@
// Package interfaces provides the core contracts for the articulate-parser application.
// It defines interfaces for parsing and exporting Articulate Rise courses.
package interfaces
import "github.com/kjanat/articulate-parser/internal/models"
// CourseParser defines the interface for loading course data.
// It provides methods to fetch course content either from a remote URI
// or from a local file path.
type CourseParser interface {
// FetchCourse loads a course from a URI (typically an Articulate Rise share URL).
// It retrieves the course data from the remote location and returns a parsed Course model.
// Returns an error if the fetch operation fails or if the data cannot be parsed.
FetchCourse(uri string) (*models.Course, error)
// LoadCourseFromFile loads a course from a local file.
// It reads and parses the course data from the specified file path.
// Returns an error if the file cannot be read or if the data cannot be parsed.
LoadCourseFromFile(filePath string) (*models.Course, error)
}