aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/conversion_tests.py31
-rw-r--r--tests/styles/parser/document_matcher_parser_tests.py12
2 files changed, 43 insertions, 0 deletions
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("<span>Hello</span>", 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("<mark>Hello</mark>", 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('<p><mark class="yellow">Yellow</mark><mark>Red</mark></p>', result.value)
+
+
def test_superscript_runs_are_wrapped_in_sup_tags():
result = convert_document_element_to_html(
documents.run(
diff --git a/tests/styles/parser/document_matcher_parser_tests.py b/tests/styles/parser/document_matcher_parser_tests.py
index 1808571..dd613a1 100644
--- a/tests/styles/parser/document_matcher_parser_tests.py
+++ b/tests/styles/parser/document_matcher_parser_tests.py
@@ -141,6 +141,18 @@ def test_reads_small_caps():
read_document_matcher("small-caps")
)
+def test_reads_highlight_without_color():
+ assert_equal(
+ document_matchers.highlight(),
+ read_document_matcher("highlight")
+ )
+
+def test_reads_highlight_with_color():
+ assert_equal(
+ document_matchers.highlight(color="yellow"),
+ read_document_matcher("highlight[color='yellow']")
+ )
+
def test_reads_comment_reference():
assert_equal(
document_matchers.comment_reference,