diff options
author | benadha <benawiadha@gmail.com> | 2022-01-07 05:47:08 +0700 |
---|---|---|
committer | benadha <benawiadha@gmail.com> | 2022-01-07 05:47:08 +0700 |
commit | 25af4c4e3adcf8318d39ffd43ee643cd7e02184b (patch) | |
tree | b8888b166db792e33f854aa35c6fd57b69da14e9 /epy.py | |
parent | edcd6d672ec6bbb9a82e41c6e6b78b43963a8bf2 (diff) | |
download | epy-25af4c4e3adcf8318d39ffd43ee643cd7e02184b.tar.gz |
Add text mark/span grouper method
Diffstat (limited to 'epy.py')
-rwxr-xr-x | epy.py | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -914,6 +914,19 @@ class HTMLtoLines(HTMLParser): return spans + @staticmethod + def _group_span_by_row( + blocks: Sequence[Union[TextMark, TextSpan]] + ) -> Mapping[int, List[Union[TextMark, TextSpan]]]: + groups: Dict[int, List[Union[TextMark, TextSpan]]] = {} + for block in blocks: + row = block.start.row + if row in groups: + groups[row].append(block) + else: + groups[row] = [block] + return groups + def __init__(self, sects={""}): HTMLParser.__init__(self) self.text = [""] |