Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 344
- Log:
Massive changeset which brings the old, ROOL customised Instiki
version up to date, but without any ROOL customisations in this
latest checked-in version (which is 0.19.1). This is deliberate,
so that it's easy to see the changes made for the ROOL version
in a subsequent changeset. The 'app/views/shared' directory is not
part of Instiki but is kept to maintain the change history with
updated ROOL customisations, some of which involve the same files
in that same directory.
- Author:
- rool
- Date:
- Sat Mar 19 19:52:13 +0000 2011
- Size:
- 38022 Bytes
1 | #!/usr/bin/env ruby |
2 | # encoding: UTF-8 |
3 | |
4 | require Rails.root.join('test', 'test_helper') |
5 | |
6 | class PageRendererTest < ActiveSupport::TestCase |
7 | fixtures :webs, :pages, :revisions, :system, :wiki_references |
8 | |
9 | def setup |
10 | @wiki = Wiki.new |
11 | @web = webs(:test_wiki) |
12 | @page = pages(:home_page) |
13 | @revision = revisions(:home_page_second_revision) |
14 | end |
15 | |
16 | def test_wiki_word_linking |
17 | @web.add_page('SecondPage', 'Yo, yo. Have you EverBeenHated', |
18 | Time.now, 'DavidHeinemeierHansson', x_test_renderer) |
19 | |
20 | assert_equal("<p>Yo, yo. Have you <span class='newWikiWord'>Ever Been Hated" + |
21 | "<a href='../show/EverBeenHated'>?</a></span></p>", |
22 | rendered_content(@web.page("SecondPage"))) |
23 | |
24 | @web.add_page('EverBeenHated', 'Yo, yo. Have you EverBeenHated', Time.now, |
25 | 'DavidHeinemeierHansson', x_test_renderer) |
26 | assert_equal("<p>Yo, yo. Have you <a class='existingWikiWord' " + |
27 | "href='../show/EverBeenHated'>Ever Been Hated</a></p>", |
28 | rendered_content(@web.page("SecondPage"))) |
29 | end |
30 | |
31 | def test_wiki_words |
32 | assert_equal %w( HisWay MyWay SmartEngine SmartEngineGUI ThatWay ), |
33 | x_test_renderer(@revision).wiki_words.sort |
34 | |
35 | @wiki.write_page('wiki1', 'NoWikiWord', 'hey you!', Time.now, 'Me', x_test_renderer) |
36 | assert_equal [], x_test_renderer(@wiki.read_page('wiki1', 'NoWikiWord').revisions.last).wiki_words |
37 | end |
38 | |
39 | def test_existing_pages |
40 | assert_equal %w( MyWay SmartEngine ThatWay ), x_test_renderer(@revision).existing_pages.sort |
41 | end |
42 | |
43 | def test_unexisting_pages |
44 | assert_equal %w( HisWay SmartEngineGUI ), x_test_renderer(@revision).unexisting_pages.sort |
45 | end |
46 | |
47 | def test_content_with_wiki_links |
48 | assert_equal "<p><span class='newWikiWord'>His Way<a href='../show/HisWay'>?</a></span> " + |
49 | "would be <a class='existingWikiWord' href='../show/MyWay'>My Way</a> " + |
50 | "<math class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Math/MathML'>" + |
51 | "<mi>sin</mi><mo stretchy='false'>(</mo><mi>x</mi><mo stretchy='false'>)</mo><semantics>" + |
52 | "<annotation-xml encoding='SVG1.1'><svg/></annotation-xml></semantics></math> in kinda " + |
53 | "<a class='existingWikiWord' href='../show/ThatWay'>That Way</a> in " + |
54 | "<span class='newWikiWord'>His Way<a href='../show/HisWay'>?</a></span> " + |
55 | %{though <a class='existingWikiWord' href='../show/MyWay'>My Way</a> OverThere \342\200\223 see } + |
56 | "<a class='existingWikiWord' href='../show/SmartEngine'>Smart Engine</a> in that " + |
57 | "<span class='newWikiWord'>Smart Engine GUI" + |
58 | "<a href='../show/SmartEngineGUI'>?</a></span></p>", |
59 | x_test_renderer(@revision).display_content |
60 | end |
61 | |
62 | def test_markdown |
63 | set_web_property :markup, :markdownMML |
64 | |
65 | assert_markup_parsed_as( |
66 | %{<p>equation <math class='maruku-mathml' } + |
67 | %{display='inline' xmlns='http://www.w3.org/1998/Math/MathML'>} + |
68 | %{<mi>sin</mi><mo stretchy='false'>(</mo><mi>x</mi><mo stretchy='false'>)</mo></math></p>}, |
69 | "equation $\\sin(x)$") |
70 | |
71 | re = Regexp.new('\\A<h1 id=\'my_headline_\\d{1,4}\'>My Headline</h1>\n\n<p>that <span class=\'newWikiWord\'>Smart Engine GUI<a href=\'../show/SmartEngineGUI\'>\?</a></span></p>\\Z') |
72 | |
73 | assert_match_markup_parsed_as(re, "My Headline\n===========\n\nthat SmartEngineGUI") |
74 | |
75 | assert_match_markup_parsed_as(re, "#My Headline#\n\nthat SmartEngineGUI") |
76 | |
77 | str1 = %{<div class='un_defn'>\n<h6 id='definition_\\d\{1,4\}'>Definition</h6>\n\n<p>Let <math} + |
78 | %{ class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>H</mi>} + |
79 | %{</math> be a subgroup of a group <math class='maruku-mathml' display='inline' xmlns='http://w} + |
80 | %{ww.w3.org/1998/Math/MathML'><mi>G</mi></math>. A <em>left coset</em> of <math class='maruku-m} + |
81 | %{athml' display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>H</mi></math> in <math} + |
82 | %{ class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>G</mi>} + |
83 | %{</math> is a subset of <math class='maruku-mathml' display='inline' xmlns='http://www.w3.org/} + |
84 | %{1998/Math/MathML'><mi>G</mi></math> that is of the form <math class='maruku-mathml' display='} + |
85 | %{inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>x</mi><mi>H</mi></math>, where <math} + |
86 | %{ class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>x</mi>} + |
87 | %{<mo>\342\210\210</mo><mi>G</mi></math> and <math class='maruku-mathml' display='inline' xmlns} + |
88 | %{='http://www.w3.org/1998/Math/MathML'><mi>x</mi><mi>H</mi><mo>=</mo><mo stretchy='false'>\\\{<} + |
89 | %{/mo><mi>x</mi><mi>h</mi><mo>:</mo><mi>h</mi><mo>\342\210\210</mo><mi>H</mi><mo stretchy='fals} + |
90 | %{e'>\\\}</mo></math>.</p>\n\n<p>Similarly a <em>right coset</em> of <math class='maruku-mathml'} + |
91 | %{ display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>H</mi></math> in <math class} + |
92 | %{='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>G</mi></math} + |
93 | %{> is a subset of <math class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/M} + |
94 | %{ath/MathML'><mi>G</mi></math> that is of the form <math class='maruku-mathml' display='inline} + |
95 | %{' xmlns='http://www.w3.org/1998/Math/MathML'><mi>H</mi><mi>x</mi></math>, where <math class='} + |
96 | %{maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>H</mi><mi>x</m} + |
97 | %{i><mo>=</mo><mo stretchy='false'>\\\{</mo><mi>h</mi><mi>x</mi><mo>:</mo><mi>h</mi><mo>\342\210\210} + |
98 | %{</mo><mi>H</mi><mo stretchy='false'>\\\}</mo></math>.</p>\n</div>\n\n} + |
99 | %{<div class='num_lemma' id='LeftCosetsDisjoint'>\n<h6 id='lemma_\\d\{1,4\}'>Lemma</h6>\n\n<p>} + |
100 | %{Let <math class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Math/MathML'>} + |
101 | %{<mi>H</mi></math> be a subgroup of a group <math class='maruku-mathml' display='inline' xmlns} + |
102 | %{='http://www.w3.org/1998/Math/MathML'><mi>G</mi></math>, and let <math class='maruku-mathml'} + |
103 | %{ display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>x</mi></math> and <math cla} + |
104 | %{ss='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>y</mi></ma} + |
105 | %{th> be elements of <math class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/} + |
106 | %{Math/MathML'><mi>G</mi></math>. Suppose that <math class='maruku-mathml' display='inline' xmln} + |
107 | %{s='http://www.w3.org/1998/Math/MathML'><mi>x</mi><mi>H</mi><mo>\342\210\251</mo><mi>y</mi><mi>} + |
108 | %{H</mi></math> is non-empty. Then <math class='maruku-mathml' display='inline' xmlns='http://ww} + |
109 | %{w.w3.org/1998/Math/MathML'><mi>x</mi><mi>H</mi><mo>=</mo><mi>y</mi><mi>H</mi></math>.</p>\n</d} + |
110 | %{iv>\n\n<div class='proof'>\n<h6 id='proof_\\d\{1,4\}'>Proof</h6>\n\n<p>Let <math class='maruku-m} + |
111 | %{athml' display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>z</mi></math> be some e} + |
112 | %{lement of <math class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Math/Math} + |
113 | %{ML'><mi>x</mi><mi>H</mi><mo>\342\210\251</mo><mi>y</mi><mi>H</mi></math>.</p>\n</div>\n\n} + |
114 | %{<div class='num_lemma' id='SizeOfLeftCoset'>\n<h6 id='lemma_\\d\{1,4\}'>Lemma</h6>\n\n<p>} + |
115 | %{Let <math class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Math/MathML'>} + |
116 | %{<mi>H</mi></math> be a finite subgroup of a group <math class='maruku-mathml' display='inline' xmlns} + |
117 | %{='http://www.w3.org/1998/Math/MathML'><mi>G</mi></math>.</p>\n</div>\n\n} + |
118 | %{<div class='num_theorem' id='Lagrange'>\n<h6 id='theorem_\\d\{1,4\}'>Theorem</h6>\n\n<p><strong>\\(Lagrange\342\200\231s Theorem\\).</strong> Let <math class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>G</mi></math> be a finite group, and let <math class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>H</mi></math> be a subgroup of <math class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>G</mi></math>.</p>\n</div>} |
119 | |
120 | str2 = <<END_THM |
121 | +-- {: .un_defn} |
122 | ###### Definition |
123 | Let $H$ be a subgroup of a group $G$. A *left coset* of $H$ in $G$ is a subset of $G$ that is of the form $x H$, where $x \\in G$ and $x H = \\{ x h : h \\in H \\}$. |
124 | |
125 | Similarly a *right coset* of $H$ in $G$ is a subset of $G$ that is of the form $H x$, where $H x = \\{ h x : h \\in H \\}$. |
126 | =-- |
127 | |
128 | +-- {: .num_lemma #LeftCosetsDisjoint} |
129 | ###### Lemma |
130 | Let $H$ be a subgroup of a group $G$, and let $x$ and $y$ be |
131 | elements of $G$. Suppose that $x H \\cap y H$ is non-empty. Then $x H = y H$. |
132 | =-- |
133 | |
134 | +-- {: .proof} |
135 | ###### Proof |
136 | Let $z$ be some element of $x H \\cap y H$. |
137 | =-- |
138 | |
139 | +-- {: .num_lemma #SizeOfLeftCoset} |
140 | ###### Lemma |
141 | Let $H$ be a finite subgroup of a group $G$. |
142 | =-- |
143 | |
144 | +-- {: .num_theorem #Lagrange} |
145 | ###### Theorem |
146 | **(Lagrange's Theorem).** Let $G$ be a finite group, and let $H$ be a subgroup of $G$. |
147 | =-- |
148 | END_THM |
149 | |
150 | assert_match_markup_parsed_as(Regexp.new(str1), str2) |
151 | |
152 | assert_markup_parsed_as( |
153 | %{<p>SVG <animateColor title='MathML'><span class='newWikiWord'>} + |
154 | %{Math ML<a href='../show/MathML'>?</a></span></animateColor></p>}, |
155 | "SVG <animateColor title='MathML'>MathML</animateColor>") |
156 | |
157 | assert_markup_parsed_as( |
158 | %{<div class='maruku-equation'><math class='maruku-mathml' display='block' } + |
159 | %{xmlns='http://www.w3.org/1998/Math/MathML'><mi>sin</mi><mo stretchy='false'>} + |
160 | %{(</mo><mi>x</mi><mo stretchy='false'>)</mo><semantics><annotation-xml encoding='SVG1.1'>} + |
161 | %{<svg/></annotation-xml></semantics></math><span class='maruku-eq-tex'><code style='display: none;'>} + |
162 | %{\\sin(x) \\begin{svg}<svg/>\\end{svg}</code></span></div>}, |
163 | "$$\\sin(x) \\begin{svg}<svg/>\\end{svg}$$") |
164 | |
165 | code_block = [ |
166 | 'This is a code block:', |
167 | '', |
168 | ' def a_method(arg)', |
169 | ' return ThatWay', |
170 | '', |
171 | 'Nice!' |
172 | ].join("\n") |
173 | |
174 | assert_markup_parsed_as( |
175 | %{<p>This is a code block:</p>\n\n<pre><code>def a_method(arg)\n} + |
176 | %{return ThatWay</code></pre>\n\n<p>Nice!</p>}, |
177 | code_block) |
178 | |
179 | assert_markup_parsed_as(%{<p>You then needed to edit (or create) a user.js file in} + |
180 | %{ your Mozilla profile, which read either (<span class='newWikiWord'>Mac OSX<a h} + |
181 | %{ref='../show/MacOSX'>?</a></span>)</p>\n\n<pre><code> user_pref("font.mat} + |
182 | %{hfont-family", "Math1,Math2,Math4,Symbol");</code></pre>}, |
183 | %{You then needed to edit (or create) a user.js file in your Mozilla profile, whic} + |
184 | %{h read either (MacOSX)\n\n user_pref("font.mathfont-family", "Math1,Math2,Math4,Symbol");}) |
185 | |
186 | assert_markup_parsed_as( |
187 | %{<p><math class='maruku-mathml' } + |
188 | %{display='inline' xmlns='http://www.w3.org/1998/Math/MathML'>} + |
189 | %{<mi>sin</mi><mo stretchy='false'>(</mo><mi>x</mi><mo stretchy='false'>)</mo></math> ecuasi\303\263n</p>}, |
190 | "$\\sin(x)$ ecuasi\303\263n") |
191 | |
192 | assert_markup_parsed_as( |
193 | %{<p>ecuasi\303\263n</p>\n<div class='maruku-equation'><math class='maruku-mathml' } + |
194 | %{display='block' xmlns='http://www.w3.org/1998/Math/MathML'><mi>sin</mi>} + |
195 | %{<mo stretchy='false'>(</mo><mi>x</mi><mo stretchy='false'>)</mo></math>} + |
196 | %{<span class='maruku-eq-tex'><code style='display: none;'>\\sin(x)</code></span></div>}, |
197 | "ecuasi\303\263n\n$$\\sin(x)$$") |
198 | |
199 | assert_markup_parsed_as( |
200 | %{<p>ecuasi\303\263n</p>\n\n<p><math class='maruku-mathml' } + |
201 | %{display='inline' xmlns='http://www.w3.org/1998/Math/MathML'>} + |
202 | %{<mi>sin</mi><mo stretchy='false'>(</mo><mi>x</mi><mo stretchy='false'>)</mo></math></p>}, |
203 | "ecuasi\303\263n \n\n$\\sin(x)$") |
204 | |
205 | assert_markup_parsed_as( |
206 | %{<p>ecuasi\303\263n <math class='maruku-mathml' } + |
207 | %{display='inline' xmlns='http://www.w3.org/1998/Math/MathML'>} + |
208 | %{<mi>sin</mi><mo stretchy='false'>(</mo><mi>x</mi><mo stretchy='false'>)</mo></math></p>}, |
209 | "ecuasi\303\263n $\\sin(x)$") |
210 | |
211 | end |
212 | |
213 | def test_ial_in_lists |
214 | |
215 | assert_markup_parsed_as( |
216 | "<ul>\n<li>item 1</li>\n\n<li style='color: red;'>" + |
217 | "item 2</li>\n\n<li>item 3 continues here</li>\n</ul>", |
218 | "* item 1\n* {: style=\"color:red\"} item 2\n* item 3\n continues here\n") |
219 | |
220 | assert_markup_parsed_as( |
221 | "<ol start='4'>\n<li>item 1</li>\n\n<li value='10'>" + |
222 | "item 2</li>\n\n<li>item 3 continues here</li>\n</ol>", |
223 | "1. item 1\n2. {: value=\"10\"} item 2\n13. item 3\n continues here\n{: start=\"4\"}") |
224 | |
225 | end |
226 | |
227 | def test_have_latest_itex2mml |
228 | |
229 | assert_markup_parsed_as( |
230 | %{<p>equation <math class='maruku-mathml' displa} + |
231 | %{y='inline' xmlns='http://www.w3.org/1998/Math/} + |
232 | %{MathML'><mi>A</mi><mi>\342\200\246</mi><mo>\342\253\275</mo><mi>B</} + |
233 | %{mi></math></p>}, |
234 | "equation $A\\dots\\sslash B$") |
235 | |
236 | assert_markup_parsed_as( |
237 | %{<p>boxed equation <math class='maruku-mathml' } + |
238 | %{display='inline' xmlns='http://www.w3.org/1998} + |
239 | %{/Math/MathML'><menclose notation='box'><mrow><} + |
240 | %{menclose notation='updiagonalstrike'><mi>D</mi} + |
241 | %{></menclose><mi>\317\210</mi><mo>=</mo><mn>0</} + |
242 | %{mn></mrow></menclose></math></p>}, |
243 | "boxed equation $\\boxed{\\slash{D}\\psi=0}$") |
244 | |
245 | assert_markup_parsed_as( |
246 | %{<p>equation <math class='maruku-mathml' displa} + |
247 | %{y='inline' xmlns='http://www.w3.org/1998/Math/} + |
248 | %{MathML'><mi>\316\265</mi><mo>\342\211\240</mo>} + |
249 | %{<mi>\317\265</mi></math></p>}, |
250 | "equation $\\varepsilon\\neq\\epsilon$") |
251 | |
252 | assert_markup_parsed_as( |
253 | %{<p>equation <math class='maruku-mathml' displa} + |
254 | %{y='inline' xmlns='http://www.w3.org/1998/Math/} + |
255 | %{MathML'><mi>A</mi><mo>=</mo><maction actiontyp} + |
256 | %{e='tooltip'><mi>B</mi><mtext>Spoons!</mtext></} + |
257 | %{maction></math></p>}, |
258 | "equation $A=\\tooltip{Spoons!}{B}$") |
259 | |
260 | assert_markup_parsed_as( |
261 | %{<p>equation <math class='maruku-mathml' displa} + |
262 | %{y='inline' xmlns='http://www.w3.org/1998/Math/} + |
263 | %{MathML'><mi>A</mi><mpadded lspace='-100%width'} + |
264 | %{ width='0'><mi>B</mi></mpadded></math></p>}, |
265 | "equation $A \\mathllap{B}$") |
266 | |
267 | assert_markup_parsed_as( |
268 | %{<p>equation <math class='maruku-mathml' displa} + |
269 | %{y='inline' xmlns='http://www.w3.org/1998/Math/} + |
270 | %{MathML'><mi>A</mi><mo>\342\211\224</mo><mi>B</} + |
271 | %{mi></math></p>}, |
272 | "equation $A \\coloneqq B$") |
273 | |
274 | assert_markup_parsed_as( |
275 | %{<p>equation <math class='maruku-mathml' displa} + |
276 | %{y='inline' xmlns='http://www.w3.org/1998/Math/} + |
277 | %{MathML'><mi>A</mi><mo>\342\206\255</mo><mi>B</} + |
278 | %{mi></math></p>}, |
279 | "equation $A \\leftrightsquigarrow B$") |
280 | |
281 | assert_markup_parsed_as( |
282 | %{<p>equation <math class='maruku-mathml' displa} + |
283 | %{y='inline' xmlns='http://www.w3.org/1998/Math/} + |
284 | %{MathML'><munder><mi>A</mi><mo>\314\262</mo></m} + |
285 | %{under></math></p>}, |
286 | "equation $\\underline{A}$") |
287 | |
288 | assert_markup_parsed_as( |
289 | %{<p>equation <math class='maruku-mathml' } + |
290 | %{display='inline' xmlns='http://www.w3.org/1998/Math/MathML'>} + |
291 | %{<mi>A</mi><mo>\342\205\213</mo><mi>B</mi></math></p>}, |
292 | "equation $A \\invamp B$") |
293 | |
294 | assert_markup_parsed_as( |
295 | %{<p>blackboard digits: <math class='maruku-mathml' display='} + |
296 | %{inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>math} + |
297 | %{bb</mi><mn>123</mn></math></p>}, |
298 | "blackboard digits: $\mathbb{123}$") |
299 | |
300 | assert_markup_parsed_as( |
301 | %{<p>\\rlap: <math class='maruku-mathml' display='} + |
302 | %{inline' xmlns='http://www.w3.org/1998/Math/MathML'>} + |
303 | %{<mn>123</mn></math></p>}, |
304 | '\rlap: $\rlap{123}$') |
305 | end |
306 | |
307 | def test_blahtex |
308 | if Kernel::system('blahtex --help > /dev/null 2>&1') |
309 | set_web_property :markup, :markdownPNG |
310 | |
311 | re = Regexp.new( |
312 | %{<p>equation <span class='maruku-inline'><img alt='\\$a\\\\sin\\(\\\\theta\\)\\$' } + |
313 | %{class='maruku-png' src='\.\./files/pngs/\\w+\.png' style='vertical-align: -0\.5} + |
314 | %{(5)+6ex; height: 2\.3(3)+ex;'/></span></p>}) |
315 | assert_match_markup_parsed_as(re, 'equation $a\sin(\theta)$') |
316 | |
317 | re = Regexp.new( |
318 | %{<div class='maruku-equation'><img alt='\\$a\\\\sin\\(\\\\theta\\)\\$' } + |
319 | %{class='maruku-png' src='\.\./files/pngs/\\w+\.png' style='height: 2\.3(3)+} + |
320 | %{33333ex;'/><span class='maruku-eq-tex'><code style='display: none;'>a\\\\sin} + |
321 | %{\\(\\\\theta\\)<\/code><\/span><\/div>}) |
322 | assert_match_markup_parsed_as(re, '$$a\sin(\theta)$$') |
323 | |
324 | else |
325 | print "\nBlahTeX not found ... skipping.\n" |
326 | end |
327 | end |
328 | |
329 | def test_markdown_hyperlink_with_slash |
330 | # in response to a bug, see http://dev.instiki.org/attachment/ticket/177 |
331 | set_web_property :markup, :markdown |
332 | |
333 | assert_markup_parsed_as( |
334 | "<p><a href='http://example/with/slash'>text</a></p>", |
335 | '[text](http://example/with/slash)') |
336 | end |
337 | |
338 | def test_mixed_formatting |
339 | textile_and_markdown = [ |
340 | 'Markdown heading', |
341 | '================', |
342 | '', |
343 | 'h2. Textile heading', |
344 | '', |
345 | '*some* **text** _with_ -styles-', |
346 | '', |
347 | '* list 1', |
348 | '* list 2' |
349 | ].join("\n") |
350 | |
351 | set_web_property :markup, :markdownMML |
352 | re = Regexp.new( |
353 | '<h1 id=\'markdown_heading_\d{1,4}\'>Markdown heading</h1>\n\n' + |
354 | "<p>h2. Textile heading</p>\n\n" + |
355 | "<p><em>some</em> <strong>text</strong> <em>with</em> -styles-</p>\n\n" + |
356 | "<ul>\n<li>list 1</li>\n\n<li>list 2</li>\n</ul>") |
357 | |
358 | assert_match_markup_parsed_as(re, textile_and_markdown) |
359 | set_web_property :markup, :textile |
360 | assert_markup_parsed_as( |
361 | "<p>Markdown heading<br/>================</p>\n\n\n\t<h2>Textile heading</h2>" + |
362 | "\n\n\n\t<p><strong>some</strong> <b>text</b> <em>with</em> <del>styles</del></p>" + |
363 | "\n\n\n\t<ul>\n\t<li>list 1</li>\n\t\t<li>list 2</li>\n\t</ul>", |
364 | textile_and_markdown) |
365 | |
366 | set_web_property :markup, :mixed |
367 | assert_markup_parsed_as( |
368 | "<h1>Markdown heading</h1>\n\n\n\t<h2>Textile heading</h2>\n\n\n\t" + |
369 | "<p><strong>some</strong> <b>text</b> <em>with</em> <del>styles</del></p>\n\n\n\t" + |
370 | "<ul>\n\t<li>list 1</li>\n\t\t<li>list 2</li>\n\t</ul>", |
371 | textile_and_markdown) |
372 | end |
373 | |
374 | def test_rdoc |
375 | set_web_property :markup, :rdoc |
376 | |
377 | @revision = Revision.new(:page => @page, :content => '+hello+ that SmartEngineGUI', |
378 | :author => Author.new('DavidHeinemeierHansson')) |
379 | |
380 | assert_equal "<tt>hello</tt> that <span class='newWikiWord'>Smart Engine GUI" + |
381 | "<a href='../show/SmartEngineGUI'>?</a></span>\n\n", |
382 | x_test_renderer(@revision).display_content |
383 | end |
384 | |
385 | # def test_content_with_auto_links |
386 | # assert_markup_parsed_as( |
387 | # '<p><a href="http://www.loudthinking.com/">http://www.loudthinking.com/</a> ' + |
388 | # 'points to <a class="existingWikiWord" href="../show/ThatWay">That Way</a> from ' + |
389 | # '<a href="mailto:david@loudthinking.com">david@loudthinking.com</a></p>', |
390 | # 'http://www.loudthinking.com/ points to ThatWay from david@loudthinking.com') |
391 | # |
392 | # end |
393 | |
394 | def test_content_with_aliased_links |
395 | assert_markup_parsed_as( |
396 | "<p>Would a <a class='existingWikiWord' href='../show/SmartEngine'>clever motor" + |
397 | '</a> go by any other name?</p>', |
398 | 'Would a [[SmartEngine|clever motor]] go by any other name?') |
399 | end |
400 | |
401 | def test_content_with_wikiword_in_em |
402 | assert_markup_parsed_as( |
403 | "<p><em>should we go <a class='existingWikiWord' href='../show/ThatWay'>" + |
404 | "That Way</a> or <span class='newWikiWord'>This Way<a href='../show/ThisWay'>?</a>" + |
405 | '</span></em></p>', |
406 | '_should we go ThatWay or ThisWay _') |
407 | end |
408 | |
409 | def test_content_with_redirected_link |
410 | assert_markup_parsed_as( |
411 | "<p>This is a redirected link: <a class='existingWikiWord' href='../show/liquor'>" + |
412 | "booze</a>. This is not: <span class='newWikiWord'>hooch<a href='../show/hooch'>?</a>" + |
413 | '</span></p>', |
414 | 'This is a redirected link: [[booze]]. This is not: [[hooch]]') |
415 | end |
416 | |
417 | def test_content_with_wikiword_in_equations |
418 | assert_markup_parsed_as( |
419 | "<p>should we go <a class='existingWikiWord' href='../show/ThatWay'>" + |
420 | "That Way</a> or</p>\n<div class='maruku-equation' id='eq:eq1'>" + |
421 | "<span class='maruku-eq-number'>(1)</span><math class='maruku-mathml' display='block' " + |
422 | "xmlns='http://www.w3.org/1998/Math/MathML'><mi>ThisWay</mi></math>" + |
423 | "<span class='maruku-eq-tex'><code style='display: none;'>ThisWay</code>" + |
424 | "</span></div>", |
425 | "should we go ThatWay or \n\\[ThisWay\\]\n") |
426 | |
427 | assert_markup_parsed_as( |
428 | "<p>should we go <a class='existingWikiWord' href='../show/ThatWay'>" + |
429 | "That Way</a> or</p>\n<div class='maruku-equation'>" + |
430 | "<math class='maruku-mathml' display='block' " + |
431 | "xmlns='http://www.w3.org/1998/Math/MathML'><mi>ThisWay</mi></math>" + |
432 | "<span class='maruku-eq-tex'><code style='display: none;'>ThisWay</code>" + |
433 | "</span></div>", |
434 | "should we go ThatWay or \n$$ThisWay$$\n") |
435 | |
436 | assert_markup_parsed_as( |
437 | "<p>should we go <a class='existingWikiWord' href='../show/ThatWay'>" + |
438 | "That Way</a> or</p>\n<div class='maruku-equation'>" + |
439 | "<math class='maruku-mathml' display='block' " + |
440 | "xmlns='http://www.w3.org/1998/Math/MathML'><mi>ThisWay</mi><mi>$</mi>" + |
441 | "<mn>100</mn><mi>ThatWay</mi></math>" + |
442 | "<span class='maruku-eq-tex'><code style='display: none;'>ThisWay \\$100 " + |
443 | "ThatWay</code></span></div>", |
444 | "should we go ThatWay or \n$$ThisWay \\$100 ThatWay $$\n") |
445 | |
446 | assert_markup_parsed_as( |
447 | "<p>should we go <a class='existingWikiWord' href='../show/ThatWay'>" + |
448 | "That Way</a> or <math class='maruku-mathml' display='inline' " + |
449 | "xmlns='http://www.w3.org/1998/Math/MathML'><mi>ThisWay</mi></math> today.</p>", |
450 | "should we go ThatWay or <math class='maruku-mathml' display='inline' " + |
451 | "xmlns='http://www.w3.org/1998/Math/MathML'><mi>ThisWay</mi></math> today.") |
452 | |
453 | assert_markup_parsed_as( |
454 | "<p>should we go <a class='existingWikiWord' href='../show/ThatWay'>" + |
455 | "That Way</a> or <math class='maruku-mathml' display='inline' " + |
456 | "xmlns='http://www.w3.org/1998/Math/MathML'><mi>ThisWay</mi></math>.</p>", |
457 | "should we go ThatWay or $ThisWay$.") |
458 | end |
459 | |
460 | def test_content_with_wikiword_in_equations_textile |
461 | set_web_property :markup, :textile |
462 | assert_markup_parsed_as( |
463 | "<p>$$<span class='newWikiWord'>foo<a href='../show/foo'>?" + |
464 | "</a></span>$$<br/>$<span class='newWikiWord'>foo<a " + |
465 | "href='../show/foo'>?</a></span>$</p>", |
466 | "$$[[foo]]$$\n$[[foo]]$") |
467 | end |
468 | |
469 | # wikiwords are invalid as styles, must be in "name: value" form |
470 | def test_content_with_wikiword_in_style_tag |
471 | assert_markup_parsed_as( |
472 | "<p>That is some <em style=''>Stylish Emphasis</em></p>", |
473 | "That is some <em style='WikiWord'>Stylish Emphasis</em>") |
474 | end |
475 | |
476 | # validates format of style.. |
477 | def test_content_with_valid_style_in_style_tag |
478 | assert_markup_parsed_as( |
479 | "<p>That is some <em style='text-align: right;'>Stylish Emphasis</em></p>", |
480 | "That is some <em style='text-align: right'>Stylish Emphasis</em>") |
481 | end |
482 | |
483 | def test_content_with_escaped_wikiword |
484 | # there should be no wiki link |
485 | assert_markup_parsed_as('<p>WikiWord</p>', '\WikiWord') |
486 | end |
487 | |
488 | def test_content_with_pre_blocks |
489 | set_web_property :markup, :markdownMML |
490 | assert_markup_parsed_as( |
491 | "<p>A <code>class SmartEngine</code> would not mark up</p>\n\n<pre><code>CodeBlocks</code></pre>\n\n<p>would it?</p>", |
492 | "A `class SmartEngine` would not mark up\n\n CodeBlocks\n\nwould it?") |
493 | assert_markup_parsed_as( |
494 | "<p>A <code>class SmartEngine</code> would not mark up</p>\n<pre>CodeBlocks</pre>\n<p>would it?</p>", |
495 | "A <code>class SmartEngine</code> would not mark up\n\n<pre>CodeBlocks</pre>\n\nwould it?") |
496 | end |
497 | |
498 | # def test_content_with_autolink_in_parentheses |
499 | # assert_markup_parsed_as( |
500 | # '<p>The W3C body (<a href="http://www.w3c.org">' + |
501 | # 'http://www.w3c.org</a>) sets web standards</p>', |
502 | # 'The W3C body (http://www.w3c.org) sets web standards') |
503 | # end |
504 | |
505 | def test_content_with_link_in_parentheses |
506 | assert_markup_parsed_as( |
507 | "<p>(<a href='http://wiki.org/wiki.cgi?WhatIsWiki'>What is a wiki?</a>)</p>", |
508 | '([What is a wiki?](http://wiki.org/wiki.cgi?WhatIsWiki))') |
509 | end |
510 | |
511 | def test_content_with_image_link |
512 | assert_markup_parsed_as( |
513 | "<p>This <img alt='' src='http://hobix.com/sample.jpg'/> is a Markdown image link.</p>", |
514 | 'This ![](http://hobix.com/sample.jpg) is a Markdown image link.') |
515 | end |
516 | |
517 | def test_content_with_inlined_img_tag |
518 | assert_markup_parsed_as( |
519 | "<p>This <img alt='' src='http://hobix.com/sample.jpg'/> is an inline image link.</p>", |
520 | 'This <img src="http://hobix.com/sample.jpg" alt="" /> is an inline image link.') |
521 | |
522 | # currently, upper case HTML elements are not allowed |
523 | assert_markup_parsed_as( |
524 | "<p>This <IMG SRC='http://hobix.com/sample.jpg' alt=''/> is an inline image link.</p>", |
525 | 'This <IMG SRC="http://hobix.com/sample.jpg" alt="" /> is an inline image link.') |
526 | end |
527 | |
528 | def test_nowiki_tag |
529 | assert_markup_parsed_as( |
530 | '<p>Do not mark up [[this text]] or http://www.thislink.com.</p>', |
531 | 'Do not mark up <nowiki>[[this text]]</nowiki> ' + |
532 | 'or <nowiki>http://www.thislink.com</nowiki>.') |
533 | end |
534 | |
535 | def test_malformed_nowiki |
536 | assert_markup_parsed_as( |
537 | '<p><i><b></i></b></p>', |
538 | '<nowiki><i><b></i></b></nowiki> ') |
539 | end |
540 | |
541 | |
542 | def test_multiline_nowiki_tag |
543 | assert_markup_parsed_as( |
544 | "<p>Do not mark \n up [[this text]] \nand http://this.url.com but markup " + |
545 | "<span class='newWikiWord'>this<a href='../show/this'>?</a></span></p>", |
546 | "Do not <nowiki>mark \n up [[this text]] \n" + |
547 | "and http://this.url.com </nowiki> but markup [[this]]") |
548 | end |
549 | |
550 | def test_markdown_nowiki_tag |
551 | assert_markup_parsed_as( |
552 | '<p>Do not mark up *this text* or http://www.thislink.com.</p>', |
553 | 'Do not mark up <nowiki>*this text*</nowiki> ' + |
554 | 'or <nowiki>http://www.thislink.com</nowiki>.') |
555 | end |
556 | |
557 | def test_sanitize_nowiki_tag |
558 | assert_markup_parsed_as( |
559 | '<p>[[test]]&<a href=\'a&b\'>shebang</a> <script>alert("xss!");</script> *foo*</p>', |
560 | '<nowiki>[[test]]&<a href="a&b">shebang</a> <script>alert("xss!");</script> *foo*</nowiki>') |
561 | end |
562 | |
563 | def test_entities |
564 | assert_markup_parsed_as( |
565 | "<p>Known: \342\210\256. Pass-through: &. Unknown: &foo;.</p>", |
566 | "Known: ∮. Pass-through: &. Unknown: &foo;.") |
567 | end |
568 | |
569 | def test_content_with_bracketted_wiki_word |
570 | set_web_property :brackets_only, true |
571 | assert_markup_parsed_as( |
572 | "<p>This is a WikiWord and a tricky name <span class='newWikiWord'>" + |
573 | "Sperberg-McQueen<a href='../show/Sperberg-McQueen'>?</a></span>.</p>", |
574 | 'This is a WikiWord and a tricky name [[Sperberg-McQueen]].') |
575 | end |
576 | |
577 | def test_content_for_export |
578 | assert_equal "<p><span class='newWikiWord'>His Way</span> would be " + |
579 | "<a class='existingWikiWord' href='MyWay.html'>My Way</a> " + |
580 | "<math class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Math/MathML'>" + |
581 | "<mi>sin</mi><mo stretchy='false'>(</mo><mi>x</mi><mo stretchy='false'>)</mo><semantics>" + |
582 | "<annotation-xml encoding='SVG1.1'><svg/></annotation-xml></semantics></math> in kinda " + |
583 | "<a class='existingWikiWord' href='ThatWay.html'>That Way</a> in " + |
584 | "<span class='newWikiWord'>His Way</span> though " + |
585 | %{<a class='existingWikiWord' href='MyWay.html'>My Way</a> OverThere \342\200\223 see } + |
586 | "<a class='existingWikiWord' href='SmartEngine.html'>Smart Engine</a> in that " + |
587 | "<span class='newWikiWord'>Smart Engine GUI</span></p>", |
588 | x_test_renderer(@revision).display_content_for_export |
589 | end |
590 | |
591 | def test_double_replacing |
592 | @revision.content = "VersionHistory\r\n\r\ncry VersionHistory" |
593 | assert_equal "<p><span class='newWikiWord'>Version History" + |
594 | "<a href='../show/VersionHistory'>?</a></span></p>\n\n<p>cry " + |
595 | "<span class='newWikiWord'>Version History<a href='../show/VersionHistory'>?</a>" + |
596 | '</span></p>', |
597 | x_test_renderer(@revision).display_content |
598 | |
599 | @revision.content = "f\r\nVersionHistory\r\n\r\ncry VersionHistory" |
600 | assert_equal "<p>f <span class='newWikiWord'>Version History" + |
601 | "<a href='../show/VersionHistory'>?</a></span></p>\n\n<p>cry " + |
602 | "<span class='newWikiWord'>Version History<a href='../show/VersionHistory'>?</a>" + |
603 | "</span></p>", |
604 | x_test_renderer(@revision).display_content |
605 | end |
606 | |
607 | def test_difficult_wiki_words |
608 | @revision.content = "[[It's just awesome GUI!]]" |
609 | assert_equal "<p><span class='newWikiWord'>It's just awesome GUI!" + |
610 | "<a href='../show/It%27s+just+awesome+GUI%21'>?</a></span></p>", |
611 | x_test_renderer(@revision).display_content |
612 | end |
613 | |
614 | def test_revisions_diff |
615 | Revision.create(:page => @page, :content => 'What a blue and lovely morning', |
616 | :author => Author.new('DavidHeinemeierHansson'), :revised_at => Time.now) |
617 | Revision.create(:page => @page, :content => 'What a red and lovely morning today', |
618 | :author => Author.new('DavidHeinemeierHansson'), :revised_at => Time.now) |
619 | |
620 | @page.reload |
621 | assert_equal "<p><span> What a<del class='diffmod'> blue</del><ins class='diffmod'> red" + |
622 | "</ins> and lovely morning<ins class='diffins'> today</ins></span></p>", x_test_renderer(@page.revisions.last).display_diff |
623 | end |
624 | |
625 | def test_nowiki_sanitization |
626 | assert_markup_parsed_as('<p>This sentence contains <span>a & b</span> ' + |
627 | '<script>alert("XSS!");</script>. Do not touch!</p>', |
628 | 'This sentence contains <nowiki><span>a & b</span> <script>alert("XSS!");' + |
629 | '</script></nowiki>. Do not touch!') |
630 | end |
631 | |
632 | def test_link_to_file |
633 | assert_markup_parsed_as( |
634 | "<p><span class='newWikiWord'>doc.pdf<a href='../file/doc.pdf'>?</a></span></p>", |
635 | '[[doc.pdf:file]]') |
636 | end |
637 | |
638 | def test_link_to_pic_and_file |
639 | WikiFile.delete_all |
640 | require 'fileutils' |
641 | FileUtils.rm_rf("#{RAILS_ROOT}/webs/wiki1/files/*") |
642 | @web.wiki_files.create(:file_name => 'square.jpg', :description => 'Square', :content => 'never mind') |
643 | assert_markup_parsed_as( |
644 | "<p><img alt='Blue Square' src='../file/square.jpg'/></p>", |
645 | '[[square.jpg|Blue Square:pic]]') |
646 | assert_markup_parsed_as( |
647 | "<p><img alt='Square' src='../file/square.jpg'/></p>", |
648 | '[[square.jpg:pic]]') |
649 | assert_markup_parsed_as( |
650 | "<p><a class='existingWikiWord' href='../file/square.jpg' title='Square'>Blue Square</a></p>", |
651 | '[[square.jpg|Blue Square:file]]') |
652 | assert_markup_parsed_as( |
653 | "<p><video controls='controls' src='../file/square.jpg'>Blue Square</video></p>", |
654 | '[[square.jpg|Blue Square:video]]') |
655 | assert_markup_parsed_as( |
656 | "<p><audio controls='controls' src='../file/square.jpg'>Blue Square</audio></p>", |
657 | '[[square.jpg|Blue Square:audio]]') |
658 | assert_markup_parsed_as( |
659 | "<p><a class='existingWikiWord' href='../file/square.jpg' title='Square'>Square</a></p>", |
660 | '[[square.jpg:file]]') |
661 | end |
662 | |
663 | def test_link_to_pic_and_file_null_desc |
664 | WikiFile.delete_all |
665 | require 'fileutils' |
666 | FileUtils.rm_rf("#{RAILS_ROOT}/webs/wiki1/files/*") |
667 | @web.wiki_files.create(:file_name => 'square.jpg', :description => '', :content => 'never mind') |
668 | assert_markup_parsed_as( |
669 | "<p><img alt='Blue Square' src='../file/square.jpg'/></p>", |
670 | '[[square.jpg|Blue Square:pic]]') |
671 | assert_markup_parsed_as( |
672 | "<p><img alt='' src='../file/square.jpg'/></p>", |
673 | '[[square.jpg:pic]]') |
674 | assert_markup_parsed_as( |
675 | "<p><a class='existingWikiWord' href='../file/square.jpg' title=''>Blue Square</a></p>", |
676 | '[[square.jpg|Blue Square:file]]') |
677 | assert_markup_parsed_as( |
678 | "<p><a class='existingWikiWord' href='../file/square.jpg' title=''></a></p>", |
679 | '[[square.jpg:file]]') |
680 | end |
681 | |
682 | def test_link_to_non_existant_pic |
683 | assert_markup_parsed_as( |
684 | "<p><span class='newWikiWord'>NonExistant<a href='../file/NonExistant.jpg'>?</a>" + |
685 | '</span></p>', |
686 | '[[NonExistant.jpg|NonExistant:pic]]') |
687 | assert_markup_parsed_as( |
688 | "<p><span class='newWikiWord'>NonExistant.jpg<a href='../file/NonExistant.jpg'>?</a>" + |
689 | '</span></p>', |
690 | '[[NonExistant.jpg:pic]]') |
691 | end |
692 | |
693 | def test_wiki_link_with_colon |
694 | assert_markup_parsed_as( |
695 | "<p><a class='existingWikiWord' href='../show/HomePage'>HomePage</a></p>", |
696 | '[[wiki1:HomePage]]') |
697 | end |
698 | |
699 | def test_wiki_link_with_colon_interwiki |
700 | assert_markup_parsed_as( |
701 | "<p><a class='existingWikiWord' href='../../instiki/show/HomePage' title='instiki'>HomePage</a></p>", |
702 | '[[instiki:HomePage]]') |
703 | end |
704 | |
705 | def test_list_with_tildas |
706 | list_with_tildas = <<-EOL |
707 | * [a](~b) |
708 | * c~ d |
709 | EOL |
710 | |
711 | assert_markup_parsed_as( |
712 | "<ul>\n<li><a href='~b'>a</a></li>\n\n<li>c~ d</li>\n</ul>", |
713 | list_with_tildas) |
714 | end |
715 | |
716 | def test_textile_image_in_mixed_wiki |
717 | set_web_property :markup, :mixed |
718 | assert_markup_parsed_as( |
719 | "<p><img alt='' src='http://google.com'/>\nss</p>", |
720 | "!http://google.com!\r\nss") |
721 | end |
722 | |
723 | |
724 | def test_references_creation_links |
725 | new_page = @web.add_page('NewPage', 'HomePage NewPage', |
726 | Time.local(2004, 4, 4, 16, 50), 'AlexeyVerkhovsky', x_test_renderer) |
727 | |
728 | references = new_page.wiki_references(true) |
729 | assert_equal 2, references.size |
730 | assert_equal 'HomePage', references[0].referenced_name |
731 | assert_equal WikiReference::LINKED_PAGE, references[0].link_type |
732 | assert_equal 'NewPage', references[1].referenced_name |
733 | assert_equal WikiReference::LINKED_PAGE, references[1].link_type |
734 | end |
735 | |
736 | def test_references_creation_includes |
737 | new_page = @web.add_page('NewPage', '[[!include IncludedPage]]', |
738 | Time.local(2004, 4, 4, 16, 50), 'AlexeyVerkhovsky', x_test_renderer) |
739 | |
740 | references = new_page.wiki_references(true) |
741 | assert_equal 1, references.size |
742 | assert_equal 'IncludedPage', references[0].referenced_name |
743 | assert_equal WikiReference::INCLUDED_PAGE, references[0].link_type |
744 | end |
745 | |
746 | def test_references_creation_categories |
747 | new_page = @web.add_page('NewPage', "Foo\ncategory: NewPageCategory", |
748 | Time.local(2004, 4, 4, 16, 50), 'AlexeyVerkhovsky', x_test_renderer) |
749 | |
750 | references = new_page.wiki_references(true) |
751 | assert_equal 1, references.size |
752 | assert_equal 'NewPageCategory', references[0].referenced_name |
753 | assert_equal WikiReference::CATEGORY, references[0].link_type |
754 | end |
755 | |
756 | def test_references_creation_sanitized_categories |
757 | new_page = @web.add_page('NewPage', "Foo\ncategory: <script>alert('XSS');</script>", |
758 | Time.local(2004, 4, 4, 16, 50), 'AlexeyVerkhovsky', x_test_renderer) |
759 | |
760 | references = new_page.wiki_references(true) |
761 | assert_equal 1, references.size |
762 | assert_equal "<script>alert('XSS');</script>", references[0].referenced_name |
763 | assert_equal WikiReference::CATEGORY, references[0].link_type |
764 | end |
765 | |
766 | def test_rendering_included_page_under_different_modes |
767 | included = @web.add_page('Included', 'link to HomePage', Time.now, 'AnAuthor', x_test_renderer) |
768 | main = @web.add_page('Main', '[[!include Included]]', Time.now, 'AnAuthor', x_test_renderer) |
769 | |
770 | assert_equal "<p>link to <a class='existingWikiWord' href='../show/HomePage'>Home Page</a></p>", |
771 | x_test_renderer(main).display_content |
772 | assert_equal "<p>link to <a class='existingWikiWord' href='../published/HomePage'>Home Page</a></p>", |
773 | x_test_renderer(main).display_published |
774 | assert_equal "<p>link to <a class='existingWikiWord' href='HomePage.html'>Home Page</a></p>", |
775 | x_test_renderer(main).display_content_for_export |
776 | end |
777 | |
778 | def test_rendering_included_page_backslashes_in_equations |
779 | included = @web.add_page('Included', '\\\\ $\begin{matrix} a \\\\ b\end{matrix}$', Time.now, 'AnAuthor', x_test_renderer) |
780 | main = @web.add_page('Main', '[[!include Included]]', Time.now, 'AnAuthor', x_test_renderer) |
781 | |
782 | assert_equal "<p>\\ <math class='maruku-mathml' display='inline' " + |
783 | "xmlns='http://www.w3.org/1998/Math/MathML'><mrow><mtable rowspacing='0.5ex'>" + |
784 | "<mtr><mtd><mi>a</mi></mtd></mtr> <mtr><mtd><mi>b</mi></mtd></mtr></mtable>" + |
785 | "</mrow></math></p>", |
786 | x_test_renderer(main).display_content |
787 | end |
788 | |
789 | private |
790 | |
791 | def add_sample_pages |
792 | @in_love = @web.add_page('EverBeenInLove', 'Who am I me', |
793 | Time.local(2004, 4, 4, 16, 50), 'DavidHeinemeierHansson', x_test_renderer) |
794 | @hated = @web.add_page('EverBeenHated', 'I am me EverBeenHated', |
795 | Time.local(2004, 4, 4, 16, 51), 'DavidHeinemeierHansson', x_test_renderer) |
796 | end |
797 | |
798 | def assert_markup_parsed_as(expected_output, input) |
799 | revision = Revision.new(:page => @page, :content => input, :author => Author.new('AnAuthor')) |
800 | assert_equal expected_output, x_test_renderer(revision).display_content(true), 'Rendering output not as expected' |
801 | end |
802 | |
803 | def assert_match_markup_parsed_as(expected_output, input) |
804 | revision = Revision.new(:page => @page, :content => input, :author => Author.new('AnAuthor')) |
805 | assert_match expected_output, x_test_renderer(revision).display_content, 'Rendering output not as expected' |
806 | end |
807 | |
808 | def rendered_content(page) |
809 | x_test_renderer(page.revisions.last).display_content |
810 | end |
811 | |
812 | end |