def html_input(x) <<~HTML blank #{x} HTML end def html_input_no_title(x) <<~HTML #{x} HTML end def html_input_empty_head(x) <<~HTML #{x} HTML end WORD_HDR = <<~HDR MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_NextPart_" ------=_NextPart_ Content-Location: file:///C:/Doc/test.htm Content-Type: text/html; charset="utf-8" blank HDR def word_body(x, fn) <<~BODY #{x} #{fn} BODY end WORD_FTR1 = <<~FTR ------=_NextPart_ Content-Location: file:///C:/Doc/test_files/filelist.xml Content-Transfer-Encoding: base64 Content-Type: application/xml PHhtbCB4bWxuczpvPSJ1cm46c2NoZW1hcy1taWNyb3NvZnQtY29tOm9mZmljZTpvZmZpY2UiPgog ICAgICAgIDxvOk1haW5GaWxlIEhSZWY9Ii4uL3Rlc3QuaHRtIi8+ICA8bzpGaWxlIEhSZWY9ImZp bGVsaXN0LnhtbCIvPgo8L3htbD4K ------=_NextPart_-- FTR WORD_FTR2 = <<~FTR ------=_NextPart_ Content-Location: file:///C:/Doc/test_files/filelist.xml Content-Transfer-Encoding: base64 Content-Type: application/xml PHhtbCB4bWxuczpvPSJ1cm46c2NoZW1hcy1taWNyb3NvZnQtY29tOm9mZmljZTpvZmZpY2UiPgog ICAgICAgIDxvOk1haW5GaWxlIEhSZWY9Ii4uL3Rlc3QuaHRtIi8+ICA8bzpGaWxlIEhSZWY9ImZp bGVsaXN0LnhtbCIvPgogIDxvOkZpbGUgSFJlZj0iaGVhZGVyLmh0bWwiLz4KPC94bWw+Cg== ------=_NextPart_ Content-Location: file:///C:/Doc/test_files/header.html Content-Transfer-Encoding: base64 Content-Type: text/html charset="utf-8" PGh0bWwgeG1sbnM6dj0idXJuOnNjaGVtYXMtbWljcm9zb2Z0LWNvbTp2bWwiDQp4bWxuczpvPSJ1 cm46c2NoZW1hcy1taWNyb3NvZnQtY29tOm9mZmljZTpvZmZpY2UiDQp4bWxuczp3PSJ1cm46c2No ZW1hcy1taWNyb3NvZnQtY29tOm9mZmljZTp3b3JkIg0KeG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bnQ6ZmllbGQtZW5kJz48L3NwYW4+PC9zcGFuPjwvYj48IVtlbmRpZl0t LT48c3Bhbg0KbGFuZz1FTi1HQiBzdHlsZT0nZm9udC1zaXplOjEwLjBwdDttc28tYmlkaS1mb250 LXNpemU6MTEuMHB0Jz48bzpwPjwvbzpwPjwvc3Bhbj48L3A+DQoNCjwvZGl2Pg0KDQo8L2JvZHk+ DQoNCjwvaHRtbD4NCg== ------=_NextPart_-- FTR WORD_FTR3 = <<~FTR ------=_NextPart_ Content-Location: file:///C:/Doc/test_files/filelist.xml Content-Transfer-Encoding: base64 Content-Type: application/xml PHhtbCB4bWxuczpvPSJ1cm46c2NoZW1hcy1taWNyb3NvZnQtY29tOm9mZmljZTpvZmZpY2UiPgog ICAgICAgIDxvOk1haW5GaWxlIEhSZWY9Ii4uL3Rlc3QuaHRtIi8+ICA8bzpGaWxlIEhSZWY9IjFh YzIwNjVmLTAzZjAtNGM3YS1iOWE2LTkyZTgyMDU5MWJmMC5wbmciLz4KICA8bzpGaWxlIEhSZWY9 ImZpbGVsaXN0LnhtbCIvPgo8L3htbD4K ------=_NextPart_ Content-Location: file:///C:/Doc/test_files/cb7b0d19-891e-4634-815a-570d019d454c.png Content-Transfer-Encoding: base64 Content-Type: image/png ------=_NextPart_-- FTR DEFAULT_STYLESHEET = File.read("lib/html2doc/wordstyle.css", encoding: "utf-8").freeze def guid_clean(x) x.gsub(/NextPart_[0-9a-f.]+/, "NextPart_") end def image_clean(x) x.gsub(%r{[0-9a-f-]+\.png}, "image.png"). gsub(%r{[0-9a-f-]+\.gif}, "image.gif"). gsub(%r{[0-9a-f-]+\.(jpeg|jpg)}, "image.jpg"). gsub(%r{------=_NextPart_\s+Content-Location: file:///C:/Doc/test_files/image\.(png|gif).*?\s-----=_NextPart_}m, "------=_NextPart_"). gsub(%r{Content-Type: image/(png|gif|jpeg)[^-]*------=_NextPart_-?-?}m, ""). gsub(%r{ICAgICAg[^-]*-----}m, "-----"). gsub(%r{\s*\s*}m, ""). gsub(%r{\s*}m, "") end RSpec.describe Html2Doc do it "has a version number" do expect(Html2Doc::VERSION).not_to be nil end it "processes a blank document" do Html2Doc.process(html_input(""), filename: "test") expect(guid_clean(File.read("test.doc", encoding: "utf-8"))). to match_fuzzy(<<~OUTPUT) #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END} #{word_body("", '
')} #{WORD_FTR1} OUTPUT end it "removes any temp files" do File.delete("test.doc") Html2Doc.process(html_input(""), filename: "test") expect(File.exist?("test.doc")).to be true expect(File.exist?("test.htm")).to be false expect(File.exist?("test_files")).to be false end it "processes a stylesheet in an HTML document with a title" do Html2Doc.process(html_input(""), filename: "test", stylesheet: "lib/html2doc/wordstyle.css") expect(guid_clean(File.read("test.doc", encoding: "utf-8"))). to match_fuzzy(<<~OUTPUT) #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END} #{word_body("", '
')} #{WORD_FTR1} OUTPUT end it "processes a stylesheet in an HTML document without a title" do Html2Doc.process(html_input_no_title(""), filename: "test", stylesheet: "lib/html2doc/wordstyle.css") expect(guid_clean(File.read("test.doc", encoding: "utf-8"))). to match_fuzzy(<<~OUTPUT) #{WORD_HDR.sub("blank", "")} #{DEFAULT_STYLESHEET} #{WORD_HDR_END} #{word_body("", '
')} #{WORD_FTR1} OUTPUT end it "processes a stylesheet in an HTML document with an empty head" do Html2Doc.process(html_input_empty_head(""), filename: "test", stylesheet: "lib/html2doc/wordstyle.css") expect(guid_clean(File.read("test.doc", encoding: "utf-8"))). to match_fuzzy(<<~OUTPUT) #{WORD_HDR.sub("blank", "")} #{DEFAULT_STYLESHEET} #{WORD_HDR_END.sub(''+"\n", "").sub("\n", "")} #{word_body("", '
')} #{WORD_FTR1} OUTPUT end it "processes a header" do Html2Doc.process(html_input(""), filename: "test", header_file: "spec/header.html") expect(guid_clean(File.read("test.doc", encoding: "utf-8"))). to match_fuzzy(<<~OUTPUT) #{WORD_HDR} #{DEFAULT_STYLESHEET.gsub(/FILENAME/, "test")} #{WORD_HDR_END} #{word_body("", '
')} #{WORD_FTR2} OUTPUT end it "processes a populated document" do simple_body = "

Hello word!

This is a very simple document
" Html2Doc.process(html_input(simple_body), filename: "test") expect(guid_clean(File.read("test.doc", encoding: "utf-8"))). to match_fuzzy(<<~OUTPUT) #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END} #{word_body(simple_body, '
')} #{WORD_FTR1} OUTPUT end it "processes AsciiMath" do Html2Doc.process(html_input("
{{sum_(i=1)^n i^3=((n(n+1))/2)^2}}
"), filename: "test", asciimathdelims: ["{{", "}}"]) expect(guid_clean(File.read("test.doc", encoding: "utf-8"))). to match_fuzzy(<<~OUTPUT) #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END} #{word_body('
i=1ni3=(n(n+1)2)2
', '
')} #{WORD_FTR1} OUTPUT end it "wraps msup after munderover in MathML" do Html2Doc.process(html_input("
i=0n2i
"), filename: "test", asciimathdelims: ["{{", "}}"]) expect(guid_clean(File.read("test.doc", encoding: "utf-8"))). to match_fuzzy(<<~OUTPUT) #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END} #{word_body('
i=0n2i
', '
')} #{WORD_FTR1} OUTPUT end it "processes tabs" do simple_body = "

Hello word!

This is a very &tab; simple document
" Html2Doc.process(html_input(simple_body), filename: "test") expect(guid_clean(File.read("test.doc", encoding: "utf-8"))). to match_fuzzy(<<~OUTPUT) #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END} #{word_body(simple_body.gsub(/\&tab;/, %[  ]), '
')} #{WORD_FTR1} OUTPUT end it "makes unstyled paragraphs be MsoNormal" do simple_body = '

Hello word!

This is a very simple document

This style stays

' Html2Doc.process(html_input(simple_body), filename: "test") expect(guid_clean(File.read("test.doc", encoding: "utf-8"))). to match_fuzzy(<<~OUTPUT) #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END} #{word_body(simple_body.gsub(/

/, %[

]), '

')} #{WORD_FTR1} OUTPUT end it "makes unstyled list entries be MsoNormal" do simple_body = '

Hello word!

  • This is a very simple document
  • This style stays
' Html2Doc.process(html_input(simple_body), filename: "test") expect(guid_clean(File.read("test.doc", encoding: "utf-8"))). to match_fuzzy(<<~OUTPUT) #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END} #{word_body(simple_body.gsub(/
  • /, %[
  • ]), '
    ')} #{WORD_FTR1} OUTPUT end it "resizes images for height" do simple_body = '' Html2Doc.process(html_input(simple_body), filename: "test") testdoc = File.read("test.doc", encoding: "utf-8") expect(testdoc).to match(%r{Content-Type: image/png}) expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT) #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END} #{image_clean(word_body('', '
    '))} #{image_clean(WORD_FTR3)} OUTPUT end it "resizes images for width" do simple_body = '' Html2Doc.process(html_input(simple_body), filename: "test") testdoc = File.read("test.doc", encoding: "utf-8") expect(testdoc).to match(%r{Content-Type: image/gif}) expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT) #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END} #{image_clean(word_body('', '
    '))} #{image_clean(WORD_FTR3).gsub(/image\.png/, "image.gif")} OUTPUT end it "resizes images for height" do simple_body = '' Html2Doc.process(html_input(simple_body), filename: "test") testdoc = File.read("test.doc", encoding: "utf-8") expect(testdoc).to match(%r{Content-Type: image/jpeg}) expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT) #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END} #{image_clean(word_body('', '
    '))} #{image_clean(WORD_FTR3).gsub(/image\.png/, "image.jpg")} OUTPUT end it "processes epub:type footnotes" do simple_body = '
    This is a very simple document1 allegedly2
    ' Html2Doc.process(html_input(simple_body), filename: "test") expect(guid_clean(File.read("test.doc", encoding: "utf-8"))). to match_fuzzy(<<~OUTPUT) #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END} #{word_body('
    This is a very simple document allegedly
    ', '

    Footnote

    Other Footnote

    ')} #{WORD_FTR1} OUTPUT end it "processes class footnotes" do simple_body = '
    This is a very simple document1 allegedly2
    ' Html2Doc.process(html_input(simple_body), filename: "test") expect(guid_clean(File.read("test.doc", encoding: "utf-8"))). to match_fuzzy(<<~OUTPUT) #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END} #{word_body('
    This is a very simple document allegedly
    ', '

    Footnote

    Other Footnote

    ')} #{WORD_FTR1} OUTPUT end it "extracts paragraphs from footnotes" do simple_body = '
    This is a very simple document1 allegedly2

    Other Footnote

    ' Html2Doc.process(html_input(simple_body), filename: "test") expect(guid_clean(File.read("test.doc", encoding: "utf-8"))). to match_fuzzy(<<~OUTPUT) #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END} #{word_body('
    This is a very simple document allegedly
    ', '

    Footnote

    Other Footnote

    ')} #{WORD_FTR1} OUTPUT end it "labels lists with list styles" do simple_body = <<~BODY
            1. A

    BODY Html2Doc.process(html_input(simple_body), filename: "test", liststyles: {ul: "l1", ol: "l2"}) expect(guid_clean(File.read("test.doc", encoding: "utf-8"))). to match_fuzzy(<<~OUTPUT) #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END} #{word_body('
            1. A

    ', '
    ')} #{WORD_FTR1} OUTPUT end end