Sablon.Parser.MailMerge (sablon v0.4.4)

Copy Markdown View Source

Finds the MailMerge fields in a document part.

Word stores merge fields in two shapes. A simple field is a single w:fldSimple element carrying the whole instruction in its w:instr attribute. A complex field is a sequence of runs delimited by w:fldChar elements, where the instruction is split across w:instrText elements and the visible text lives after the separate marker. Both are represented here so the rest of the pipeline does not have to care which is which.

Summary

Functions

Returns every valid merge field inside xml_node, in document order.

Functions

parse_fields(xml_node)

Returns every valid merge field inside xml_node, in document order.

Fields that are malformed - a complex field without a separate marker, or an instruction that is not a MERGEFIELD - are skipped.