Documentation
¶
Index ¶
Constants ¶
const COPYRIGHT = "(c) Xavier Gandillot 2024"
const NAME = "mydocx"
const NAMESPACE = "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
const VERSION = "0.1.9"
Variables ¶
var VERBOSE = false
if true, verbose information will be printed to stdout
Functions ¶
func ExtractText ¶
Extract text content from docx file for external processing. Returns a map from the container name (eg : word/footer1.xml) to a list of text contained in its paragraphs.
func ModifyText ¶
All text from the sourceFile is modified by applying the replace function to it. Before applying the function, the whole paragraph is collected as a single text, even if split on multiple runs. Replace function is called paragraph by paragraph. No special assupmtion is made for empty paragraph. If the replace function is nil, text will be copied unmodified (but paragraph format WILL be extended from the start of paragraph, removing internal paragraph formatting !). If the targetFile name is empty, the sourceFile will be used, modification will be done in place.
Types ¶
type Replacer ¶
A replacer replaces a string with a modified string. It is provide the container name where replacement will occur ("word/document.xm", "word/footer1.xml", ...). Only documents, headers and footers will be submitted. It returns a flag that can trigger the removal of the entire paragraph. You may design your own Replacer, without relying on the go template engine (or using another one).
func NewTplReplacer ¶
Assume the source word document contains valid template in each paragraph (CAUTION template logic cannot extend beyond paragraph boundaries !) NewTplReplacer creates a replacer that will apply the provided content struct to the template in each paragraph. Container is ignored. By default, this Replacer will discard the entire paragraph if it was not initailly empty but becomes empty when executing the template. If an error occurs during template conversion, the text of the error is returned, together with the original text that triggered the error.
func NewTplReplacerNoDiscard ¶
same as NewTplReplacer but will never discard empty paragraphs.