Relocate the in-house OOXML machinery out of internal/services into the
first docforge adapter, with zero behaviour change:
submission_merge.go -> pkg/docforge/docx/merge.go (placeholder
substitution renderer + preview-HTML emitter)
submission_md.go -> pkg/docforge/docx/markdown.go (Markdown->OOXML
walker incl. the b78a984 underscore-fix)
submission_render.go -> pkg/docforge/docx/dotm.go (.dotm->.docx)
+ their _test.go files (git-tracked renames, 84-99% identical)
internal/services keeps thin type-alias + forwarder shims
(docforge_shims.go) so every caller in services/handlers/main compiles
and behaves identically: PlaceholderMap, MissingPlaceholderFn,
SubmissionRenderer, HyperlinkAllocator (aliases); NewSubmissionRenderer,
DefaultMissingMarker, RenderMarkdownToOOXML[WithStyles], ConvertDotmToDocx,
SanitiseSubmissionFileName (forwarders). docx.XMLAttrEscape is exported so
submission_compose.go's hyperlink-rels inserts reuse the walker's escaping.
Three mis-filed pretty-printer tests (legalSourcePretty, ourSideDE/EN,
patentNumberUPC) that exercise the vars layer move back to
internal/services/submission_vars_pretty_test.go.
Placeholder grammar + PlaceholderMap stay co-located with the renderer in
docx for now; slice 3 hoists the format-neutral grammar to the docforge
root with the VariableResolver interface.
Verification: go build ./... clean, go vet clean, full module test green
(the byte-exact OOXML golden tests in merge/compose/render pass unchanged
= behaviour preserved). gofmt drift on the moved files is pre-existing
(72/169 services files already drift; no gofmt gate).
m/paliad#157
29 lines
1.6 KiB
Go
29 lines
1.6 KiB
Go
// Package docx is docforge's .docx (OOXML) adapter — the first
|
|
// format adapter in the docforge engine (t-paliad-349 / m/paliad#157).
|
|
//
|
|
// It owns the in-house OOXML machinery extracted from paliad's submission
|
|
// generator in slice 1, with no behaviour change:
|
|
//
|
|
// - merge.go — the placeholder substitution renderer
|
|
// (SubmissionRenderer.Render / RenderHTML). Two-pass {{placeholder}}
|
|
// substitution (single-run, then cross-run merge for fragmented
|
|
// placeholders), plus the preview-HTML emitter that wraps substituted
|
|
// values in clickable <span class="draft-var" data-var="…"> markup.
|
|
// - markdown.go — the Markdown→OOXML walker (RenderMarkdownToOOXML*),
|
|
// including the b78a984 fix that preserves {{…}} placeholders verbatim
|
|
// through inline-span parsing (underscores in keys survive).
|
|
// - dotm.go — ConvertDotmToDocx: strips macros from a .dotm/.docm/
|
|
// .dotx and rewrites the content-types + rels to a clean .docx,
|
|
// passing every other part through bit-for-bit.
|
|
//
|
|
// Why no third-party docx library: lukasjarosch/go-docx treats sibling
|
|
// placeholders in one run ("{{a}} ./. {{b}}") as nested and refuses to
|
|
// replace either; patent submissions routinely have several placeholders
|
|
// per paragraph, so this in-house renderer is required. See merge.go.
|
|
//
|
|
// The placeholder grammar — \{\{\s*([A-Za-z][A-Za-z0-9_.]*)\s*\}\} — and
|
|
// the PlaceholderMap type currently live here with the renderer; a later
|
|
// slice hoists the format-neutral grammar up to the docforge root once
|
|
// the neutral document model and the VariableResolver interface land.
|
|
package docx
|