Changeset 391c90a
- Timestamp:
- 08/10/10 23:19:47 (3 years ago)
- Branches:
- master
- Children:
- 07f45f5
- Parents:
- d577fa9
- git-author:
- Aurélien Bompard <aurelien@…> (08/10/10 23:19:47)
- git-committer:
- Aurélien Bompard <aurelien@…> (08/10/10 23:19:47)
- Files:
-
- 4 edited
-
tests/data/1.xml (modified) (1 diff)
-
tests/test_specific.py (modified) (2 diffs)
-
xsl/specific/pygments.xsl (modified) (4 diffs)
-
xsl/styles/highlight.xsl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/data/1.xml
r6734727 r391c90a 603 603 Perl: 604 604 </text:p> 605 <text:p xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" text:style-name="Preformatted_20_Text"><text:span text:style-name="strong">my</text:span> ($test) <text:span text:style-name="strong">=</text:span> <text:span text:style-name="syntax-highlight. int">0</text:span>;<text:line-break/><text:span text:style-name="strong">if</text:span> ($test <text:span text:style-name="strong">></text:span> <text:span text:style-name="syntax-highlight.int">0</text:span>) {<text:line-break/> <text:span text:style-name="strong">print</text:span> <text:span text:style-name="syntax-highlight.string">"hello"</text:span>;<text:line-break/>}</text:p><text:p xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" text:style-name="Text_20_body">605 <text:p xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" text:style-name="Preformatted_20_Text"><text:span text:style-name="strong">my</text:span> ($test) <text:span text:style-name="strong">=</text:span> <text:span text:style-name="syntax-highlight.number">0</text:span>;<text:line-break/><text:span text:style-name="strong">if</text:span> ($test <text:span text:style-name="strong">></text:span> <text:span text:style-name="syntax-highlight.number">0</text:span>) {<text:line-break/> <text:span text:style-name="strong">print</text:span> <text:span text:style-name="syntax-highlight.string">"hello"</text:span>;<text:line-break/>}</text:p><text:p xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" text:style-name="Text_20_body"> 606 606 See <text:a xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="/wiki/WikiProcessors">WikiProcessors</text:a> for more information. 607 607 </text:p> -
tests/test_specific.py
r6734727 r391c90a 24 24 self.assertEquals(str(odt),"") 25 25 26 def test_highlight_k(self): 27 html = '<html xmlns="http://www.w3.org/1999/xhtml"><div class="code"><pre><span class="k">Test</span></pre></div></html>' 26 27 class SpecificPygments(unittest.TestCase): 28 29 def _test_mapping(self, css, odtstyle): 30 html = '<html xmlns="http://www.w3.org/1999/xhtml"><div class="code"><pre><span class="%s">Test</span></pre></div></html>' % css 28 31 odt = xhtml2odt(html) 29 32 print odt 30 33 self.assertEquals(str(odt), """<?xml version="1.0" encoding="utf-8"?> 31 34 <text:p xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" text:style-name="Preformatted_20_Text"> 32 <text:span text:style-name=" strong">Test</text:span>35 <text:span text:style-name="%s">Test</text:span> 33 36 </text:p> 34 """) 37 """ % odtstyle) 38 39 def test_highlight_k(self): 40 self._test_mapping("k", "strong") 41 42 def test_highlight_kn(self): 43 self._test_mapping("kn", "strong") 35 44 36 45 def test_highlight_nc(self): 37 html = '<html xmlns="http://www.w3.org/1999/xhtml"><div class="code"><pre><span class="nc">Test</span></pre></div></html>' 38 odt = xhtml2odt(html) 39 print odt 40 self.assertEquals(str(odt), """<?xml version="1.0" encoding="utf-8"?> 41 <text:p xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" text:style-name="Preformatted_20_Text"> 42 <text:span text:style-name="syntax-highlight.class">Test</text:span> 43 </text:p> 44 """) 46 self._test_mapping("nc", "syntax-highlight.class") 47 48 def test_highlight_nf(self): 49 self._test_mapping("nf", "syntax-highlight.function") 50 51 def test_highlight_nt(self): 52 self._test_mapping("nt", "syntax-highlight.tag") 53 54 def test_highlight_na(self): 55 self._test_mapping("na", "syntax-highlight.attr") 56 57 def test_highlight_nb(self): 58 self._test_mapping("nb", "syntax-highlight.builtin") 59 60 def test_highlight_nn(self): 61 self._test_mapping("nn", "syntax-highlight.namespace") 62 63 def test_highlight_ne(self): 64 self._test_mapping("ne", "syntax-highlight.exception") 45 65 46 66 def test_highlight_p(self): … … 52 72 """) 53 73 54 def test_highlight_nf(self):55 html = '<html xmlns="http://www.w3.org/1999/xhtml"><div class="code"><pre><span class="nf">Test</span></pre></div></html>'56 odt = xhtml2odt(html)57 print odt58 self.assertEquals(str(odt), """<?xml version="1.0" encoding="utf-8"?>59 <text:p xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" text:style-name="Preformatted_20_Text">60 <text:span text:style-name="syntax-highlight.function">Test</text:span>61 </text:p>62 """)63 64 74 def test_highlight_bp(self): 65 html = '<html xmlns="http://www.w3.org/1999/xhtml"><div class="code"><pre><span class="bp">Test</span></pre></div></html>' 66 odt = xhtml2odt(html) 67 print odt 68 self.assertEquals(str(odt), """<?xml version="1.0" encoding="utf-8"?> 69 <text:p xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" text:style-name="Preformatted_20_Text"> 70 <text:span text:style-name="syntax-highlight.builtin.pseudo">Test</text:span> 71 </text:p> 72 """) 75 self._test_mapping("bp", "syntax-highlight.builtin.pseudo") 73 76 74 77 def test_highlight_s(self): 75 html = '<html xmlns="http://www.w3.org/1999/xhtml"><div class="code"><pre><span class="s">Test</span></pre></div></html>' 76 odt = xhtml2odt(html) 77 print odt 78 self.assertEquals(str(odt), """<?xml version="1.0" encoding="utf-8"?> 79 <text:p xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" text:style-name="Preformatted_20_Text"> 80 <text:span text:style-name="syntax-highlight.string">Test</text:span> 81 </text:p> 82 """) 78 self._test_mapping("s", "syntax-highlight.string") 79 80 def test_highlight_sd(self): 81 self._test_mapping("sd", "syntax-highlight.string") 82 83 def test_highlight_si(self): 84 self._test_mapping("si", "syntax-highlight.string") 85 86 def test_highlight_se(self): 87 self._test_mapping("se", "syntax-highlight.string") 83 88 84 89 def test_highlight_o(self): 85 html = '<html xmlns="http://www.w3.org/1999/xhtml"><div class="code"><pre><span class="o">Test</span></pre></div></html>' 86 odt = xhtml2odt(html) 87 print odt 88 self.assertEquals(str(odt), """<?xml version="1.0" encoding="utf-8"?> 89 <text:p xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" text:style-name="Preformatted_20_Text"> 90 <text:span text:style-name="strong">Test</text:span> 91 </text:p> 92 """) 90 self._test_mapping("o", "strong") 91 92 def test_highlight_ow(self): 93 self._test_mapping("ow", "strong") 94 95 def test_highlight_c(self): 96 self._test_mapping("c", "syntax-highlight.comment") 97 98 def test_highlight_err(self): 99 self._test_mapping("err", "syntax-highlight.error") 100 101 def test_highlight_mi(self): 102 self._test_mapping("mi", "syntax-highlight.number") 103 104 def test_highlight_mf(self): 105 self._test_mapping("mf", "syntax-highlight.number") 93 106 94 107 -
xsl/specific/pygments.xsl
r6734727 r391c90a 113 113 </xsl:template> 114 114 115 <!-- Name.Exception --> 116 <xsl:template match="h:div[@class='code']/h:pre/h:span[@class='ne']" mode="inparagraph"> 117 <text:span text:style-name="syntax-highlight.exception"> 118 <xsl:apply-templates mode="inparagraph"/> 119 </text:span> 120 </xsl:template> 121 115 122 <!-- Punctuation --> 116 123 <xsl:template match="h:div[@class='code']/h:pre/h:span[@class='p']" mode="inparagraph"> … … 132 139 </xsl:template> 133 140 141 <!-- String.Double --> 142 <xsl:template match="h:div[@class='code']/h:pre/h:span[@class='sd']" mode="inparagraph"> 143 <text:span text:style-name="syntax-highlight.string"> 144 <xsl:apply-templates mode="inparagraph"/> 145 </text:span> 146 </xsl:template> 147 148 <!-- String.Interpol --> 149 <xsl:template match="h:div[@class='code']/h:pre/h:span[@class='si']" mode="inparagraph"> 150 <text:span text:style-name="syntax-highlight.string"> 151 <xsl:apply-templates mode="inparagraph"/> 152 </text:span> 153 </xsl:template> 154 155 <!-- String.Escape --> 156 <xsl:template match="h:div[@class='code']/h:pre/h:span[@class='se']" mode="inparagraph"> 157 <text:span text:style-name="syntax-highlight.string"> 158 <xsl:apply-templates mode="inparagraph"/> 159 </text:span> 160 </xsl:template> 161 134 162 <!-- Operator --> 135 163 <xsl:template match="h:div[@class='code']/h:pre/h:span[@class='o']" mode="inparagraph"> 164 <text:span text:style-name="strong"> 165 <xsl:apply-templates mode="inparagraph"/> 166 </text:span> 167 </xsl:template> 168 169 <!-- Operator.Word --> 170 <xsl:template match="h:div[@class='code']/h:pre/h:span[@class='ow']" mode="inparagraph"> 136 171 <text:span text:style-name="strong"> 137 172 <xsl:apply-templates mode="inparagraph"/> … … 155 190 <!-- Number.Integer --> 156 191 <xsl:template match="h:div[@class='code']/h:pre/h:span[@class='mi']" mode="inparagraph"> 157 <text:span text:style-name="syntax-highlight. int">192 <text:span text:style-name="syntax-highlight.number"> 158 193 <xsl:apply-templates mode="inparagraph"/> 159 194 </text:span> … … 162 197 <!-- Number.Float --> 163 198 <xsl:template match="h:div[@class='code']/h:pre/h:span[@class='mf']" mode="inparagraph"> 164 <text:span text:style-name="syntax-highlight. float">199 <text:span text:style-name="syntax-highlight.number"> 165 200 <xsl:apply-templates mode="inparagraph"/> 166 201 </text:span> -
xsl/styles/highlight.xsl
r6734727 r391c90a 90 90 </xsl:if> 91 91 92 <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'syntax-highlight.exception']) = 0"> 93 <style:style style:name="syntax-highlight.exception" style:family="text"> 94 <style:text-properties fo:color="#990000" 95 fo:font-weight="bold"/> 96 </style:style> 97 </xsl:if> 98 92 99 <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'syntax-highlight.builtin.pseudo']) = 0"> 93 100 <style:style style:name="syntax-highlight.builtin.pseudo" style:family="text"> … … 116 123 </xsl:if> 117 124 118 <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'syntax-highlight.int']) = 0"> 119 <style:style style:name="syntax-highlight.int" style:family="text"> 120 <style:text-properties fo:color="#009999"/> 121 </style:style> 122 </xsl:if> 123 124 <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'syntax-highlight.float']) = 0"> 125 <style:style style:name="syntax-highlight.float" style:family="text"> 125 <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'syntax-highlight.number']) = 0"> 126 <style:style style:name="syntax-highlight.number" style:family="text"> 126 127 <style:text-properties fo:color="#009999"/> 127 128 </style:style>
Note: See TracChangeset
for help on using the changeset viewer.
