def _prepare_mustache_template(document: Document): """Prepares mustache compatible template from OpenXML template file :param document: Document node of document.xml file If the paragraph contains. """ for paragraph in document.getElementsByTagNameNS(_namespaces['w'], 'p'): _merge_placeholder_broken_inside_runs_if_required(paragraph) for paragraph in document.getElementsByTagNameNS(_namespaces['w'], 'p'): text = get_text_from_paragraph_runs(paragraph) if re.search(MUSTACHE_LOOP_REGEX, text): _replace_loop_placeholder(paragraph, text)