From fe7708b65b7d479e795f379e11ab486d2d08af4e Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 30 Nov 2024 12:07:59 +0000 Subject: Convert checkbox document elements to HTML checkboxes --- mammoth/conversion.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'mammoth/conversion.py') diff --git a/mammoth/conversion.py b/mammoth/conversion.py index 33f61cc..f320471 100644 --- a/mammoth/conversion.py +++ b/mammoth/conversion.py @@ -165,6 +165,15 @@ class _DocumentConverter(documents.element_visitor(args=1)): return [html.collapsible_element("a", attributes, nodes)] + def visit_checkbox(self, checkbox, context): + attributes = {"type": "checkbox"} + + if checkbox.checked: + attributes["checked"] = "checked" + + return [html.element("input", attributes)] + + def visit_bookmark(self, bookmark, context): element = html.collapsible_element( "a", -- cgit v1.2.3