def wrap_with_abbreviation(abbr, text, syntax="html", profile="plain"): """ Wraps passed text with abbreviation. Text will be placed inside last expanded element @param abbr: Abbreviation @type abbr: str @param text: Text to wrap @type text: str @param syntax: Document type (html, xml, etc.) @type syntax: str @param profile: Output profile's name. @type profile: str @return {String} """ tree_root = utils.parse_into_tree(abbr, syntax) pasted = False if tree_root: if tree_root.multiply_elem: # we have a repeating element, put content in tree_root.multiply_elem.set_paste_content(text) tree_root.multiply_elem.repeat_by_lines = pasted = True tree = utils.rollout_tree(tree_root) if not pasted: tree.paste_content(text) utils.apply_filters(tree, syntax, profile, tree_root.filters) return utils.replace_variables(tree.to_string()) return None
def wrap_with_abbreviation(abbr, text, syntax='html', profile='plain'): """ Wraps passed text with abbreviation. Text will be placed inside last expanded element @param abbr: Abbreviation @type abbr: str @param text: Text to wrap @type text: str @param syntax: Document type (html, xml, etc.) @type syntax: str @param profile: Output profile's name. @type profile: str @return {String} """ tree_root = utils.parse_into_tree(abbr, syntax) pasted = False if tree_root: if tree_root.multiply_elem: # we have a repeating element, put content in tree_root.multiply_elem.set_paste_content(text) tree_root.multiply_elem.repeat_by_lines = pasted = True tree = utils.rollout_tree(tree_root) if not pasted: tree.paste_content(text) utils.apply_filters(tree, syntax, profile, tree_root.filters) return utils.replace_variables(tree.to_string()) return None
def expand_abbreviation(abbr, syntax='html', profile_name='plain'): """ Expands abbreviation into a XHTML tag string @type abbr: str @return: str """ tree_root = utils.parse_into_tree(abbr, syntax) if tree_root: tree = utils.rollout_tree(tree_root) utils.apply_filters(tree, syntax, profile_name, tree_root.filters) return utils.replace_variables(tree.to_string()) return ''