chore: adopt remote dprint config, tidy examples

Extend dprint from a shared remote config and add the prettier
and exec plugins, formatting TOML via a new tombi.toml instead
of golangci-lint fmt. Taskfile.yml, scripts/build.sh, and
html_styles.css pick up the resulting reformat.

Exporter examples now write to a temp dir and clean up after
themselves instead of leaving output.md/.docx/.html in the
repo. Drop the stray internal/exporters/output.docx and ignore
internal/exporters/output.* going forward.
This commit is contained in:
2026-09-21 09:47:10 +02:00
parent defce7d2d3
commit 7d3487312f
8 changed files with 285 additions and 233 deletions
+22 -3
View File
@@ -4,12 +4,25 @@ package exporters_test
import (
"fmt"
"log"
"os"
"path/filepath"
"github.com/kjanat/articulate-parser/internal/exporters"
"github.com/kjanat/articulate-parser/internal/models"
"github.com/kjanat/articulate-parser/internal/services"
)
// tempOutput returns a path inside a fresh temp dir plus a cleanup func, so
// example exports don't pollute the package source tree. Example functions
// can't take *testing.T, so t.TempDir is unavailable here.
func tempOutput(name string) (path string, cleanup func()) {
dir, err := os.MkdirTemp("", "exporters-example-*")
if err != nil {
log.Fatal(err)
}
return filepath.Join(dir, name), func() { _ = os.RemoveAll(dir) }
}
// ExampleNewFactory demonstrates creating an exporter factory.
func ExampleNewFactory() {
htmlCleaner := services.NewHTMLCleaner()
@@ -69,7 +82,9 @@ func ExampleMarkdownExporter_Export() {
}
// Export to markdown file
err := exporter.Export(course, "output.md")
out, cleanup := tempOutput("output.md")
defer cleanup()
err := exporter.Export(course, out)
if err != nil {
log.Fatal(err)
}
@@ -91,7 +106,9 @@ func ExampleDocxExporter_Export() {
}
// Export to Word document
err := exporter.Export(course, "output.docx")
out, cleanup := tempOutput("output.docx")
defer cleanup()
err := exporter.Export(course, out)
if err != nil {
log.Fatal(err)
}
@@ -121,7 +138,9 @@ func ExampleHTMLExporter_Export() {
}
// Export to HTML file
err := exporter.Export(course, "output.html")
out, cleanup := tempOutput("output.html")
defer cleanup()
err := exporter.Export(course, out)
if err != nil {
log.Fatal(err)
}
+8 -2
View File
@@ -1,7 +1,13 @@
body {
font-family:
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
Cantarell, sans-serif;
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
Oxygen,
Ubuntu,
Cantarell,
sans-serif;
line-height: 1.6;
color: #333;
max-width: 800px;
Binary file not shown.