feat: add DOCX/HTML output, go-tomd reverse converter, and input/output flags

- go-mdtopdf-helper: -format pdf,html,docx; new internal/document writers
  (standalone HTML, pure Go DOCX)
- new go-tomd command converting PDF/HTML/DOCX back to Markdown, skipping
  existing .md files unless -force
- -input/-output on both commands (single file with chosen name, or output
  directory mirroring the scan layout)
- restructure README and build config (Makefile, goreleaser) for both binaries
This commit is contained in:
Hein committed 2026-10-08 17:05:01 +02:00
1 parent 50b7246c21
commit 5bf9c3673d
17 files changed
+1903 -84

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
package tomd
import (
"fmt"
"strings"
"github.com/JohannesKaufmann/html-to-markdown/v2/converter"
"github.com/JohannesKaufmann/html-to-markdown/v2/plugin/base"
"github.com/JohannesKaufmann/html-to-markdown/v2/plugin/commonmark"
"github.com/JohannesKaufmann/html-to-markdown/v2/plugin/strikethrough"
"github.com/JohannesKaufmann/html-to-markdown/v2/plugin/table"
)
// HTML converts an HTML document or fragment to Markdown.
func HTML(data []byte) ([]byte, error) {
conv := converter.NewConverter(converter.WithPlugins(
base.NewBasePlugin(),
commonmark.NewCommonmarkPlugin(),
strikethrough.NewStrikethroughPlugin(),
table.NewTablePlugin(),
))
md, err := conv.ConvertString(string(data))
if err != nil {
return nil, fmt.Errorf("failed to convert HTML: %w", err)
}
return []byte(strings.TrimSpace(md) + "\n"), nil
}