RedCloth 4.1.1-x86-mswin32-60 → 4.1.9-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of RedCloth might be problematic. Click here for more details.

@@ -14,14 +14,6 @@ module RedCloth::Formatters::LATEX
14
14
 
15
15
  RedCloth::TextileDoc.send(:include, Settings)
16
16
 
17
- def escape(text)
18
- latex_esc(text)
19
- end
20
-
21
- def escape_pre(text)
22
- text
23
- end
24
-
25
17
  # headers
26
18
  { :h1 => 'section*',
27
19
  :h2 => 'subsection*',
@@ -38,7 +30,7 @@ module RedCloth::Formatters::LATEX
38
30
  # commands
39
31
  { :strong => 'textbf',
40
32
  :em => 'emph',
41
- :i => 'emph',
33
+ :i => 'textit',
42
34
  :b => 'textbf',
43
35
  :ins => 'underline',
44
36
  :del => 'sout',
@@ -102,24 +94,50 @@ module RedCloth::Formatters::LATEX
102
94
  end
103
95
 
104
96
  def td(opts)
105
- "\t\t\t#{opts[:text]} &\n"
97
+ column = @table_row.size
98
+ if opts[:colspan]
99
+ opts[:text] = "\\multicolumn{#{opts[:colspan]}}{ #{"l " * opts[:colspan].to_i}}{#{opts[:text]}}"
100
+ end
101
+ if opts[:rowspan]
102
+ @table_multirow_next[column] = opts[:rowspan].to_i - 1
103
+ opts[:text] = "\\multirow{#{opts[:rowspan]}}{*}{#{opts[:text]}}"
104
+ end
105
+ @table_row.push(opts[:text])
106
+ return ""
106
107
  end
107
108
 
108
109
  def tr_open(opts)
109
- "\t\t"
110
+ @table_row = []
111
+ return ""
110
112
  end
111
113
 
112
114
  def tr_close(opts)
113
- "\t\t\\\\\n"
115
+ multirow_columns = @table_multirow.find_all {|c,n| n > 0}
116
+ multirow_columns.each do |c,n|
117
+ @table_row.insert(c,"")
118
+ @table_multirow[c] -= 1
119
+ end
120
+ @table_multirow.merge!(@table_multirow_next)
121
+ @table_multirow_next = {}
122
+ @table.push(@table_row)
123
+ return ""
114
124
  end
115
125
 
116
- # FIXME: we need to know the column count before opening tabular context.
126
+ # We need to know the column count before opening tabular context.
117
127
  def table_open(opts)
118
- "\\begin{align*}\n"
128
+ @table = []
129
+ @table_multirow = {}
130
+ @table_multirow_next = {}
131
+ return ""
119
132
  end
120
133
 
121
134
  def table_close(opts)
122
- "\t\\end{align*}\n"
135
+ output = "\\begin{tabular}{ #{"l " * @table[0].size }}\n"
136
+ @table.each do |row|
137
+ output << " #{row.join(" & ")} \\\\\n"
138
+ end
139
+ output << "\\end{tabular}\n"
140
+ output
123
141
  end
124
142
 
125
143
  def bc_open(opts)
@@ -222,12 +240,22 @@ module RedCloth::Formatters::LATEX
222
240
  end
223
241
 
224
242
  def dim(opts)
225
- space = opts[:space] ? " " : ''
226
- "#{opts[:text]}#{space}\\texttimes{}#{space}"
243
+ opts[:text].gsub!('x', '\times')
244
+ opts[:text].gsub!('"', "''")
245
+ period = opts[:text].slice!(/\.$/)
246
+ "$#{opts[:text]}$#{period}"
227
247
  end
228
248
 
229
249
  private
230
250
 
251
+ def escape(text)
252
+ latex_esc(text)
253
+ end
254
+
255
+ def escape_pre(text)
256
+ text
257
+ end
258
+
231
259
  # Use this for block level commands that use \begin
232
260
  def begin_chunk(type)
233
261
  chunk_counter[type] += 1
@@ -30,9 +30,7 @@ module RedCloth
30
30
  # Traditional RedCloth converted single newlines
31
31
  # to HTML break tags, but later versions required
32
32
  # +:hard_breaks+ be set to enable this behavior.
33
- # +:hard_breaks+ is once again the default. The
34
- # accessor is deprecated and will be removed in a
35
- # future version.
33
+ # +:hard_breaks+ is once again the default.
36
34
  #
37
35
  attr_accessor :hard_breaks
38
36
 
@@ -2,7 +2,7 @@ module RedCloth
2
2
  module VERSION
3
3
  MAJOR = 4
4
4
  MINOR = 1
5
- TINY = 1
5
+ TINY = 9
6
6
  RELEASE_CANDIDATE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY].join('.')
Binary file
@@ -164,27 +164,33 @@ name: dimension sign
164
164
  desc: The letter 'x' becomes a dimension sign when used between digits.
165
165
  in: "Observe: 2x3."
166
166
  html: "<p>Observe: 2&#215;3.</p>"
167
+ latex: "Observe: $2\\times3$.\n\n"
167
168
  ---
168
169
  name: dimension sign with space after
169
170
  in: "The room is 2x3 inches big."
170
171
  html: "<p>The room is 2&#215;3 inches big.</p>"
172
+ latex: "The room is $2\\times3$ inches big.\n\n"
171
173
  ---
172
174
  name: dimension sign with spaces
173
175
  in: "Observe: 2 x 4."
174
176
  html: "<p>Observe: 2 &#215; 4.</p>"
177
+ latex: "Observe: $2 \\times 4$.\n\n"
175
178
  ---
176
179
  name: dimension signs chained
177
180
  in: "Observe: 2x3x4."
178
181
  html: "<p>Observe: 2&#215;3&#215;4.</p>"
179
182
  lite_mode_html: "Observe: 2&#215;3&#215;4."
183
+ latex: "Observe: $2\\times3\\times4$.\n\n"
180
184
  ---
181
185
  name: dimension signs with double primes
182
186
  in: 'My mouse: 2.5" x 4".'
183
187
  html: '<p>My mouse: 2.5&#8243; &#215; 4&#8243;.</p>'
188
+ latex: "My mouse: $2.5'' \\times 4''$.\n\n"
184
189
  ---
185
190
  name: dimension signs with single primes
186
191
  in: "My office: 5' x 4.5'."
187
192
  html: "<p>My office: 5&#8242; &#215; 4.5&#8242;.</p>"
193
+ latex: "My office: $5' \\times 4.5'$.\n\n"
188
194
  ---
189
195
  name: trademark and copyright
190
196
  desc: Conversion of trademark and copyright symbols.
@@ -266,7 +272,11 @@ html: <p>Please email why@domain.com or jason@domain.com.</p>
266
272
  name: del
267
273
  desc: To indicate a passage which has been deleted, surround the passage with hypens.
268
274
  in: I'm -sure- not sure.
269
- html: <p>I&#8217;m <del>sure</del> not sure.</p>
275
+ html: "<p>I&#8217;m <del>sure</del> not sure.</p>"
276
+ ---
277
+ name: del beginning a phrase
278
+ in: -delete-
279
+ html: "<p><del>delete</del></p>"
270
280
  ---
271
281
  name: ins
272
282
  desc: Pluses around a passage indicate its insertion.
@@ -915,4 +925,8 @@ in: |-
915
925
  html: |-
916
926
  <p>Just some <em>_</em> text</p>
917
927
  <hr />
918
- <p>Some more text.</p>
928
+ <p>Some more text.</p>
929
+ ---
930
+ name: lang attribute cannot contain square brackets
931
+ in: "some @[[code]]@"
932
+ html: "<p>some <code>[[code]]</code></p>"
@@ -96,7 +96,10 @@ in: |-
96
96
  <notextile>
97
97
  # *test*
98
98
  html: |-
99
- # *test*
99
+ <p><notextile></p>
100
+ <ol>
101
+ <li><strong>test</strong></li>
102
+ </ol>
100
103
  valid_html: false
101
104
  ---
102
105
  name: unfinished script tag
@@ -140,9 +143,7 @@ html: |-
140
143
  <pre><code>./foo.pl%
141
144
  &lt;p&gt;foo outputs an HTML paragraph&lt;/p&gt;</code>
142
145
 
143
- <code>&lt;p&gt;block of code keeps going until a different block signature is encountered&lt;/p&gt;</code>
144
-
145
- </pre>
146
+ <code>&lt;p&gt;block of code keeps going until a different block signature is encountered&lt;/p&gt;</code></pre>
146
147
  <p>And then go back with a normal paragraph.</p>
147
148
  ---
148
149
  name: extended block code preserves leading whitespace after blank line
@@ -167,9 +168,7 @@ html: |-
167
168
  <code> def baz
168
169
  'baz'
169
170
  end
170
- end</code>
171
-
172
- </pre>
171
+ end</code></pre>
173
172
  <p>That&#8217;s it!</p>
174
173
  ---
175
174
  name: block code containing code avoids nesting code tags
@@ -308,4 +308,18 @@ name: objects in paragraphs are not modified
308
308
  in: |-
309
309
  <p><object width="340" height="280"><param name="movie" value="http://www.youtube.com/v/iUbK1cBHm6E"></param><param name="wmode" value="opaque"></param><param name="allowScriptAccess" value="sameDomain"></param><embed src="http://www.youtube.com/v/iUbK1cBHm6E" type="application/x-shockwave-flash" width="340" height="280" wmode="opaque" allowScriptAccess="sameDomain"></embed></object></p>
310
310
  html: |-
311
- <p><object width="340" height="280"><param name="movie" value="http://www.youtube.com/v/iUbK1cBHm6E"></param><param name="wmode" value="opaque"></param><param name="allowScriptAccess" value="sameDomain"></param><embed src="http://www.youtube.com/v/iUbK1cBHm6E" type="application/x-shockwave-flash" width="340" height="280" wmode="opaque" allowScriptAccess="sameDomain"></embed></object></p>
311
+ <p><object width="340" height="280"><param name="movie" value="http://www.youtube.com/v/iUbK1cBHm6E"></param><param name="wmode" value="opaque"></param><param name="allowScriptAccess" value="sameDomain"></param><embed src="http://www.youtube.com/v/iUbK1cBHm6E" type="application/x-shockwave-flash" width="340" height="280" wmode="opaque" allowScriptAccess="sameDomain"></embed></object></p>
312
+ ---
313
+ name: in code escaped properly
314
+ in: "<pre><code>some <b>bold</b> text</code></pre>"
315
+ html: "<pre><code>some &lt;b&gt;bold&lt;/b&gt; text</code></pre>"
316
+ ---
317
+ name: in code with class attribute escaped properly
318
+ in: "<pre><code class='myclass'>some <b>bold</b> text</code></pre>"
319
+ html: "<pre><code class='myclass'>some &lt;b&gt;bold&lt;/b&gt; text</code></pre>"
320
+ ---
321
+ name: notextile beginning the line
322
+ in: |-
323
+ <notextile><a href="http://a.com">Sir Bobby Robson</a></notextile>, is a famous footballer
324
+ html: |-
325
+ <p><a href="http://a.com">Sir Bobby Robson</a>, is a famous footballer</p>
@@ -244,3 +244,26 @@ latex: |+
244
244
  name: image attributes has single quote html entity in alt and title
245
245
  in: "!/pictures/bacon.jpg(The fox said: 'Have some chunky bacon')!"
246
246
  html: '<p><img src="/pictures/bacon.jpg" title="The fox said: &#39;Have some chunky bacon&#39;" alt="The fox said: &#39;Have some chunky bacon&#39;" /></p>'
247
+ ---
248
+ name: in square brackets
249
+ in: This is an [!image.jpg!] you see.
250
+ html: <p>This is an <img src="image.jpg" alt="" /> you see.</p>
251
+ ---
252
+ name: with link in square brackets
253
+ in: This is an [!image.jpg!:http://example.com/] you see.
254
+ html: <p>This is an <a href="http://example.com/"><img src="image.jpg" alt="" /></a> you see.</p>
255
+ ---
256
+ name: url containing parentheses
257
+ in: "!http://commons.wikimedia.org/wiki/File:Rubis_sur_calcite_2(Vietnam).jpg!"
258
+ html: |-
259
+ <p><img src="http://commons.wikimedia.org/wiki/File:Rubis_sur_calcite_2(Vietnam).jpg" alt="" /></p>
260
+ ---
261
+ name: with alt and url containing parentheses
262
+ in: "!http://commons.wikimedia.org/wiki/File:Rubis_sur_calcite_2(Vietnam).jpg(a big rock)!"
263
+ html: |-
264
+ <p><img src="http://commons.wikimedia.org/wiki/File:Rubis_sur_calcite_2(Vietnam).jpg" title="a big rock" alt="a big rock" /></p>
265
+ ---
266
+ name: with link that contains parentheses
267
+ in: "!image.jpg(Alt text with (parentheses).)!"
268
+ html: |-
269
+ <p><img src="image.jpg" title="Alt text with (parentheses)." alt="Alt text with (parentheses)." /></p>
@@ -185,10 +185,14 @@ name: trailing period stays outside link
185
185
  in: '"Link":/foo.html.'
186
186
  html: "<p><a href=\"/foo.html\">Link</a>.</p>"
187
187
  ---
188
- name: parenthetical statement as a link
188
+ name: whose text is a parenthetical statement
189
189
  in: '"(just in case you were wondering)":http://slashdot.org/'
190
190
  html: '<p><a href="http://slashdot.org/">(just in case you were wondering)</a></p>'
191
191
  ---
192
+ name: that has a class and whose text is a parenthetical statement
193
+ in: '"(myclass) (just in case you were wondering)":http://slashdot.org/'
194
+ html: '<p><a href="http://slashdot.org/" class="myclass">(just in case you were wondering)</a></p>'
195
+ ---
192
196
  name: link containing parentheses
193
197
  in: '"It is (very) fortunate that this works":http://slashdot.org/'
194
198
  html: '<p><a href="http://slashdot.org/">It is (very) fortunate that this works</a></p>'
@@ -221,6 +225,22 @@ name: links contained in parentheses
221
225
  in: 'This is a regular link (but in parentheses: "Google":http://www.google.com)'
222
226
  html: '<p>This is a regular link (but in parentheses: <a href="http://www.google.com">Google</a>)</p>'
223
227
  ---
228
+ name: links containing parentheses without brackets
229
+ in: 'This is a link to a "Wikipedia article about Textile":http://en.wikipedia.org/wiki/Textile_(markup_language)'
230
+ html: '<p>This is a link to a <a href="http://en.wikipedia.org/wiki/Textile_(markup_language)">Wikipedia article about Textile</a></p>'
231
+ ---
232
+ name: links containing parentheses period at end without brackets
233
+ in: 'This is a link to a "Wikipedia article about Textile":http://en.wikipedia.org/wiki/Textile_(markup_language).'
234
+ html: '<p>This is a link to a <a href="http://en.wikipedia.org/wiki/Textile_(markup_language)">Wikipedia article about Textile</a>.</p>'
235
+ ---
236
+ name: broken links containing parentheses without brackets
237
+ in: 'This is a link to a "Wikipedia article about Textile":http://en.wikipedia.org/wiki/Textile_(markup_language'
238
+ html: '<p>This is a link to a <a href="http://en.wikipedia.org/wiki/Textile_(markup_language">Wikipedia article about Textile</a></p>'
239
+ ---
240
+ name: links containing parentheses without brackets inside a parenthesis
241
+ in: 'Textile is awesome! (Check out the "Wikipedia article about Textile":http://en.wikipedia.org/wiki/Textile_(markup_language))'
242
+ html: '<p>Textile is awesome! (Check out the <a href="http://en.wikipedia.org/wiki/Textile_(markup_language)">Wikipedia article about Textile</a>)</p>'
243
+ ---
224
244
  name: quotes and follow link
225
245
  in: 'Some "text" followed by a "link":http://redcloth.org.'
226
246
  html: '<p>Some &#8220;text&#8221; followed by a <a href="http://redcloth.org">link</a>.</p>'
@@ -257,3 +277,9 @@ in: |-
257
277
  "My wife, Tipper, and I will donate 100% of the proceeds of the award to the "Alliance For Climate Protection":http://www.looktothestars.org/charity/638-alliance-for-climate-protection," said Gore in an email. "I am deeply honored to receive the Nobel Peace Prize."
258
278
  html: |-
259
279
  <p>&#8220;My wife, Tipper, and I will donate 100% of the proceeds of the award to the <a href="http://www.looktothestars.org/charity/638-alliance-for-climate-protection">Alliance For Climate Protection</a>,&#8221; said Gore in an email. &#8220;I am deeply honored to receive the Nobel Peace Prize.&#8221;</p>
280
+ ---
281
+ name: with caps in the title
282
+ in: |-
283
+ "British Skin Foundation (BSF)":http://www.britishskinfoundation.org.uk
284
+ html: |-
285
+ <p><a href="http://www.britishskinfoundation.org.uk" title="BSF">British Skin Foundation</a></p>
@@ -280,4 +280,22 @@ html: |-
280
280
  <ul>
281
281
  <li>One</li>
282
282
  <li>Two</li>
283
- </ul>
283
+ </ul>
284
+ ---
285
+ name: unordered list with leading spaces
286
+ in: " * notice the leading space\n * RedCloth 3.0.4 used to accept it\n * Now we do too"
287
+ html: |-
288
+ <ul>
289
+ <li>notice the leading space</li>
290
+ <li>RedCloth 3.0.4 used to accept it</li>
291
+ <li>Now we do too</li>
292
+ </ul>
293
+ ---
294
+ name: ordered list with leading spaces
295
+ in: " # notice the leading space\n # RedCloth 3.0.4 used to accept it\n # Now we do too"
296
+ html: |-
297
+ <ol>
298
+ <li>notice the leading space</li>
299
+ <li>RedCloth 3.0.4 used to accept it</li>
300
+ <li>Now we do too</li>
301
+ </ol>
@@ -18,6 +18,13 @@ html: |-
18
18
  </tr>
19
19
  </table>
20
20
  <h3>A header after the table</h3>
21
+ latex: |+
22
+ \begin{tabular}{ l l l }
23
+ a & b & c \\
24
+ 1 & 2 & 3 \\
25
+ \end{tabular}
26
+ \subsubsection*{A header after the table}
27
+
21
28
  ---
22
29
  in: |
23
30
  |_. a|_. b|_. c|
@@ -56,6 +63,11 @@ html: |-
56
63
  <td>row</td>
57
64
  </tr>
58
65
  </table>
66
+ latex: |+
67
+ \begin{tabular}{ l l l l l }
68
+ This & is & a & simple & table \\
69
+ This & is & a & simple & row \\
70
+ \end{tabular}
59
71
  ---
60
72
  in: |-
61
73
  table{border:1px solid black}.
@@ -144,25 +156,82 @@ html: |-
144
156
  </table>
145
157
  ---
146
158
  in: |-
147
- |{background:#ddd}. Cell with gray background|
159
+ |{background:#ddd}. Cell with gray background|Normal cell|
148
160
  |\2. Cell spanning 2 columns|
149
- |/3. Cell spanning 3 rows|
150
- |>. Right-aligned cell|
161
+ |/2. Cell spanning 2 rows|one|
162
+ |two|
163
+ |>. Right-aligned cell|<. Left-aligned cell|
151
164
  html: |-
152
165
  <table>
153
166
  <tr>
154
167
  <td style="background:#ddd;">Cell with gray background</td>
168
+ <td>Normal cell</td>
155
169
  </tr>
156
170
  <tr>
157
171
  <td colspan="2">Cell spanning 2 columns</td>
158
172
  </tr>
159
173
  <tr>
160
- <td rowspan="3">Cell spanning 3 rows</td>
174
+ <td rowspan="2">Cell spanning 2 rows</td>
175
+ <td>one</td>
176
+ </tr>
177
+ <tr>
178
+ <td>two</td>
161
179
  </tr>
162
180
  <tr>
163
181
  <td style="text-align:right;">Right-aligned cell</td>
182
+ <td style="text-align:left;">Left-aligned cell</td>
183
+ </tr>
184
+ </table>
185
+ latex: |+
186
+ \begin{tabular}{ l l }
187
+ Cell with gray background & Normal cell \\
188
+ \multicolumn{2}{ l l }{Cell spanning 2 columns} \\
189
+ \multirow{2}{*}{Cell spanning 2 rows} & one \\
190
+ & two \\
191
+ Right-aligned cell & Left-aligned cell \\
192
+ \end{tabular}
193
+ ---
194
+ name: row spanning mid-row
195
+ in: |-
196
+ |1|2|3|
197
+ |1|/3. 2|3|
198
+ |1|3|
199
+ |1|3|
200
+ |1|2|3|
201
+ html: |-
202
+ <table>
203
+ <tr>
204
+ <td>1</td>
205
+ <td>2</td>
206
+ <td>3</td>
207
+ </tr>
208
+ <tr>
209
+ <td>1</td>
210
+ <td rowspan="3">2</td>
211
+ <td>3</td>
212
+ </tr>
213
+ <tr>
214
+ <td>1</td>
215
+ <td>3</td>
216
+ </tr>
217
+ <tr>
218
+ <td>1</td>
219
+ <td>3</td>
220
+ </tr>
221
+ <tr>
222
+ <td>1</td>
223
+ <td>2</td>
224
+ <td>3</td>
164
225
  </tr>
165
226
  </table>
227
+ latex: |+
228
+ \begin{tabular}{ l l l }
229
+ 1 & 2 & 3 \\
230
+ 1 & \multirow{3}{*}{2} & 3 \\
231
+ 1 & & 3 \\
232
+ 1 & & 3 \\
233
+ 1 & 2 & 3 \\
234
+ \end{tabular}
166
235
  ---
167
236
  in: |
168
237
  {background:#ddd}. |S|Target|Complete|App|Milestone|