aeidon.Parser¶
Source: aeidon/parser.py
Anchestors: aeidon.finder.Finder, builtins.object
- class aeidon.Parser¶
Text parser for markup-tag-aware text editing.
- Parser.clean_func¶
Function to clean tags or None
- Parser.re_tag¶
Regular expression object to match any tag
The purpose of Parser is to split text to the actual text and its markup tags, allowing the text to be edited while keeping its tags separate and intact. An example would be replacing all “i”s with “j”s without changing italic markup:
>>> import re >>> parser = aeidon.Parser(re.compile(r"<.+?>")) >>> parser.set_text("<i>iii</i>") >>> parser.pattern = "i" >>> parser.replacement = "j" >>> parser.replace_all() 3 >>> parser.get_text() '<i>jjj</i>'