| 1 | #!/usr/bin/env python |
|---|
| 2 | # -*- coding: utf-8 -*- |
|---|
| 3 | |
|---|
| 4 | import unittest |
|---|
| 5 | from lxml import etree |
|---|
| 6 | from . import xhtml2odt |
|---|
| 7 | |
|---|
| 8 | class SpecificTrac(unittest.TestCase): |
|---|
| 9 | |
|---|
| 10 | def test_underline(self): |
|---|
| 11 | html = '<html xmlns="http://www.w3.org/1999/xhtml"><p><span class="underline">Test</span></p></html>' |
|---|
| 12 | odt = xhtml2odt(html) |
|---|
| 13 | self.assertEquals(odt, """<text:p text:style-name="Text_20_body"> |
|---|
| 14 | <text:span text:style-name="underline">Test</text:span> |
|---|
| 15 | </text:p>""") |
|---|
| 16 | |
|---|
| 17 | def test_underline_outside_p(self): |
|---|
| 18 | html = '<html xmlns="http://www.w3.org/1999/xhtml"><span class="underline">Test</span></html>' |
|---|
| 19 | odt = xhtml2odt(html) |
|---|
| 20 | self.assertEquals(odt, "") |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | class SpecificPygments(unittest.TestCase): |
|---|
| 24 | |
|---|
| 25 | def _test_mapping(self, css, odtstyle): |
|---|
| 26 | html = '<html xmlns="http://www.w3.org/1999/xhtml"><div class="code"><pre><span class="%s">Test</span></pre></div></html>' % css |
|---|
| 27 | odt = xhtml2odt(html) |
|---|
| 28 | self.assertEquals(odt, """<text:p text:style-name="Source_20_Code"> |
|---|
| 29 | <text:span text:style-name="%s">Test</text:span> |
|---|
| 30 | </text:p><text:p text:style-name="Text_20_body"/>""" % odtstyle) |
|---|
| 31 | |
|---|
| 32 | def test_highlight_k(self): |
|---|
| 33 | self._test_mapping("k", "strong") |
|---|
| 34 | |
|---|
| 35 | def test_highlight_kn(self): |
|---|
| 36 | self._test_mapping("kn", "strong") |
|---|
| 37 | |
|---|
| 38 | def test_highlight_nc(self): |
|---|
| 39 | self._test_mapping("nc", "syntax-highlight.class") |
|---|
| 40 | |
|---|
| 41 | def test_highlight_nf(self): |
|---|
| 42 | self._test_mapping("nf", "syntax-highlight.function") |
|---|
| 43 | |
|---|
| 44 | def test_highlight_nt(self): |
|---|
| 45 | self._test_mapping("nt", "syntax-highlight.tag") |
|---|
| 46 | |
|---|
| 47 | def test_highlight_na(self): |
|---|
| 48 | self._test_mapping("na", "syntax-highlight.attr") |
|---|
| 49 | |
|---|
| 50 | def test_highlight_nb(self): |
|---|
| 51 | self._test_mapping("nb", "syntax-highlight.builtin") |
|---|
| 52 | |
|---|
| 53 | def test_highlight_nn(self): |
|---|
| 54 | self._test_mapping("nn", "syntax-highlight.namespace") |
|---|
| 55 | |
|---|
| 56 | def test_highlight_ne(self): |
|---|
| 57 | self._test_mapping("ne", "syntax-highlight.exception") |
|---|
| 58 | |
|---|
| 59 | def test_highlight_nv(self): |
|---|
| 60 | self._test_mapping("nv", "syntax-highlight.var") |
|---|
| 61 | |
|---|
| 62 | def test_highlight_bp(self): |
|---|
| 63 | self._test_mapping("bp", "syntax-highlight.builtin.pseudo") |
|---|
| 64 | |
|---|
| 65 | def test_highlight_s(self): |
|---|
| 66 | self._test_mapping("s", "syntax-highlight.string") |
|---|
| 67 | |
|---|
| 68 | def test_highlight_sd(self): |
|---|
| 69 | self._test_mapping("sd", "syntax-highlight.string") |
|---|
| 70 | |
|---|
| 71 | def test_highlight_si(self): |
|---|
| 72 | self._test_mapping("si", "syntax-highlight.string") |
|---|
| 73 | |
|---|
| 74 | def test_highlight_se(self): |
|---|
| 75 | self._test_mapping("se", "syntax-highlight.string") |
|---|
| 76 | |
|---|
| 77 | def test_highlight_sb(self): |
|---|
| 78 | self._test_mapping("sb", "syntax-highlight.string") |
|---|
| 79 | |
|---|
| 80 | def test_highlight_s2(self): |
|---|
| 81 | self._test_mapping("s2", "syntax-highlight.string") |
|---|
| 82 | |
|---|
| 83 | def test_highlight_mi(self): |
|---|
| 84 | self._test_mapping("mi", "syntax-highlight.number") |
|---|
| 85 | |
|---|
| 86 | def test_highlight_mf(self): |
|---|
| 87 | self._test_mapping("mf", "syntax-highlight.number") |
|---|
| 88 | |
|---|
| 89 | def test_highlight_o(self): |
|---|
| 90 | self._test_mapping("o", "strong") |
|---|
| 91 | |
|---|
| 92 | def test_highlight_ow(self): |
|---|
| 93 | self._test_mapping("ow", "strong") |
|---|
| 94 | |
|---|
| 95 | def test_highlight_p(self): |
|---|
| 96 | html = '<html xmlns="http://www.w3.org/1999/xhtml"><div class="code"><pre><span class="p">Test</span></pre></div></html>' |
|---|
| 97 | odt = xhtml2odt(html) |
|---|
| 98 | self.assertEquals(odt, """<text:p text:style-name="Source_20_Code">Test</text:p>""" |
|---|
| 99 | """<text:p text:style-name="Text_20_body"/>""") |
|---|
| 100 | |
|---|
| 101 | def test_highlight_c(self): |
|---|
| 102 | self._test_mapping("c", "syntax-highlight.comment") |
|---|
| 103 | |
|---|
| 104 | def test_highlight_err(self): |
|---|
| 105 | self._test_mapping("err", "syntax-highlight.error") |
|---|
| 106 | |
|---|
| 107 | |
|---|
| 108 | if __name__ == '__main__': |
|---|
| 109 | unittest.main() |
|---|