From 4a779b8d4fe83a80d99324a947b714c76468a88f Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 13 Jun 2024 12:16:25 +0100 Subject: Support style mapping for highlights --- tests/conversion_tests.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests/conversion_tests.py') diff --git a/tests/conversion_tests.py b/tests/conversion_tests.py index 8f02048..8e76714 100644 --- a/tests/conversion_tests.py +++ b/tests/conversion_tests.py @@ -242,6 +242,37 @@ def test_small_caps_runs_can_be_mapped_using_style_mapping(): assert_equal("Hello", result.value) +def test_highlighted_runs_are_ignored_by_default(): + result = convert_document_element_to_html( + documents.run(children=[documents.text("Hello")], highlight="yellow"), + ) + assert_equal("Hello", result.value) + + +def test_highlighted_runs_can_be_configured_with_style_mapping_for_all_highlights(): + result = convert_document_element_to_html( + documents.run(children=[documents.text("Hello")], highlight="yellow"), + style_map=[ + _style_mapping("highlight => mark"), + ], + ) + assert_equal("Hello", result.value) + + +def test_highlighted_runs_can_be_configured_with_style_mapping_for_specific_highlight_color(): + result = convert_document_element_to_html( + documents.paragraph(children=[ + documents.run(children=[documents.text("Yellow")], highlight="yellow"), + documents.run(children=[documents.text("Red")], highlight="red"), + ]), + style_map=[ + _style_mapping("highlight[color='yellow'] => mark.yellow"), + _style_mapping("highlight => mark"), + ] + ) + assert_equal('

YellowRed

', result.value) + + def test_superscript_runs_are_wrapped_in_sup_tags(): result = convert_document_element_to_html( documents.run( -- cgit v1.2.3