diff --git a/README.md b/README.md index 10aa0bf..b0cefd7 100644 --- a/README.md +++ b/README.md @@ -134,10 +134,11 @@ All standard html elements are supported and will create the closest equivalent ### Highlighting text -You can add highlighting to text by wrapping it in a span with class h and adding a data style with a color that wordml supports (http://www.schemacentral.com/sc/ooxml/t-w_ST_HighlightColor.html) ie: +You can add highlighting to text by wrapping it in a span with class h and adding a data style with a color that wordml supports (http://www.schemacentral.com/sc/ooxml/t-w_ST_HighlightColor.html) or a HEX color value ie: ```html This text will have a green highlight +This text will have a light gray highlight ``` ### Page breaks diff --git a/docs/styles.md b/docs/styles.md index 7c177c4..5303088 100644 --- a/docs/styles.md +++ b/docs/styles.md @@ -16,9 +16,10 @@ Returns a page break Highlighted Text Here -Will highlight text +Will highlight text with predefined color -As per: http://www.schemacentral.com/sc/ooxml/t-w_ST_HighlightColor.html these are your color choices +You can specify the color as 6 character HEX color (e.g. `FFFFFF` for white, `FF00000` for red) or one of the following +text values: Valid value | Description -------------- | ---------------- @@ -40,6 +41,8 @@ darkGray | Dark Gray Highlighting Color lightGray | Light Gray Highlighting Color none | No Text Highlighting +As per: http://www.schemacentral.com/sc/ooxml/t-w_ST_HighlightColor.html + ### Text Align (not in readme) It looks like adding the following classes will align text in your word document appropriately. diff --git a/lib/htmltoword/xslt/base.xslt b/lib/htmltoword/xslt/base.xslt index 585e73b..6891e5d 100644 --- a/lib/htmltoword/xslt/base.xslt +++ b/lib/htmltoword/xslt/base.xslt @@ -266,12 +266,20 @@ + - + + + + + + + + @@ -280,7 +288,14 @@ - + + + + + + + + diff --git a/spec/xslt_simple_text_style_spec.rb b/spec/xslt_simple_text_style_spec.rb index 764815f..a56f97b 100644 --- a/spec/xslt_simple_text_style_spec.rb +++ b/spec/xslt_simple_text_style_spec.rb @@ -142,6 +142,65 @@ compare_resulting_wordml_with_expected(html, expected_wordml.strip) end + it "transforms text color classes" do + html = <<-EOL + + + + +
Testing grey text
+

Testing grey text

+ Testing grey text + + + EOL + expected_wordml = <<-EOL + + + Testing + + + + + + grey + + + text + + + + + Testing + + + + + + grey + + + text + + + + + Testing + + + + + + grey + + + text + + + EOL + compare_resulting_wordml_with_expected(html, expected_wordml.strip) + end + it "transforms all combinations of b, strong, em and italic within div and p" do html = <<-EOL