diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-02-17 13:52:16 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-02-17 13:52:16 +0000 |
| commit | fe41ddbc51b4b7c6ce7d958ea7622983d7805b7e (patch) | |
| tree | 6a477e4a54657b5b89b87141ed85f088c2f03015 /mammoth/html_paths.py | |
| parent | d037ef5cf7fc976047bed20859dbcd5c90f45d67 (diff) | |
Support attributes in HTML paths in style mappings
Diffstat (limited to 'mammoth/html_paths.py')
| -rw-r--r-- | mammoth/html_paths.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/mammoth/html_paths.py b/mammoth/html_paths.py index c91813a..a8fb952 100644 --- a/mammoth/html_paths.py +++ b/mammoth/html_paths.py @@ -7,15 +7,16 @@ def path(elements): return HtmlPath(elements) -def element(names, class_names=None, fresh=None, separator=None): +def element(names, attributes=None, class_names=None, fresh=None, separator=None): + if attributes is None: + attributes = {} if class_names is None: class_names = [] if fresh is None: fresh = False if class_names: - attributes = {"class": " ".join(class_names)} - else: - attributes = {} + attributes["class"] = " ".join(class_names) + return HtmlPathElement(html.tag( tag_names=names, attributes=attributes, @@ -27,13 +28,13 @@ def element(names, class_names=None, fresh=None, separator=None): @cobble.data class HtmlPath(object): elements = cobble.field() - + def wrap(self, generate_nodes): nodes = generate_nodes() for element in reversed(self.elements): nodes = element.wrap_nodes(nodes) - + return nodes |
