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.6"
Variables ¶
This section is empty.
Functions ¶
func ExtractText ¶
Extract text content from docx file for external processing. The slice of strings contains a string, possibly empty, for each paragraph.
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 provides 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. 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.