Implement many more nodes
All checks were successful
CI Pipeline / build (pull_request) Successful in 12s
All checks were successful
CI Pipeline / build (pull_request) Successful in 12s
Adds these new styling and formatting nodes * strike * highlight * linebreaks * pagebreaks * Hyperlinks
This commit is contained in:
@@ -168,4 +168,56 @@ class StyleTest < Minitest::Test
|
||||
assert_includes styles_xml, 'w:ascii="Arial"'
|
||||
assert_includes styles_xml, '<w:jc w:val="center"'
|
||||
end
|
||||
|
||||
def test_style_with_highlight
|
||||
xml_files = create_doc_and_read_all_xml do |doc|
|
||||
doc.define_style :highlighted, highlight: "yellow"
|
||||
doc.p "Highlighted", style: :highlighted
|
||||
end
|
||||
|
||||
styles_xml = xml_files["word/styles.xml"]
|
||||
assert_includes styles_xml, '<w:highlight w:val="yellow"'
|
||||
end
|
||||
|
||||
def test_style_with_strikethrough
|
||||
xml_files = create_doc_and_read_all_xml do |doc|
|
||||
doc.define_style :deleted, strike: true
|
||||
doc.p "Deleted", style: :deleted
|
||||
end
|
||||
|
||||
styles_xml = xml_files["word/styles.xml"]
|
||||
assert_includes styles_xml, "<w:strike/>"
|
||||
end
|
||||
|
||||
def test_invalid_highlight_raises_error
|
||||
assert_raises(ArgumentError) do
|
||||
Notare::Style.new(:bad, highlight: "invalid_color")
|
||||
end
|
||||
end
|
||||
|
||||
def test_valid_highlight_colors
|
||||
# Test a few valid highlight colors
|
||||
%w[yellow red blue green cyan magenta].each do |color|
|
||||
style = Notare::Style.new(:test, highlight: color)
|
||||
assert_equal color, style.highlight
|
||||
end
|
||||
end
|
||||
|
||||
def test_highlight_in_text_run
|
||||
xml_files = create_doc_and_read_all_xml do |doc|
|
||||
doc.define_style :yellow_highlight, highlight: "yellow"
|
||||
doc.p do
|
||||
doc.text "Normal "
|
||||
doc.text "highlighted", style: :yellow_highlight
|
||||
end
|
||||
end
|
||||
|
||||
# Highlight is in the style definition, not inline when using style reference
|
||||
styles_xml = xml_files["word/styles.xml"]
|
||||
assert_includes styles_xml, '<w:highlight w:val="yellow"'
|
||||
|
||||
document_xml = xml_files["word/document.xml"]
|
||||
assert_includes document_xml, '<w:rStyle w:val="YellowHighlight"'
|
||||
assert_includes document_xml, "highlighted"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user