git.iko.soy/typeable/pandoc
on master help sign in
Added needed space after .bc and .bq.

Otherwise these can trap a </dd>, for example. Better solution to try next: rewrite using Pretty.

commit65a015e74b326ca1bf88cf458629726a801d2fa3 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 23 Jan 2011, 10:08 (16 years ago) parent16d4366
3 files changed+172−148
src/Text/Pandoc/Writers/Textile.hs+15−15 tests/tables.textile+53−53 tests/writer.textile+104−80
src/Text/Pandoc/Writers/Textile.hs+15−15
@@ -106,7 +106,7 @@ blockToTextile opts (Para inlines) = do
106106 listLevel <- liftM stListLevel get
107107 contents <- inlineListToTextile opts inlines
108108 return $ if useTags
109− then " <p>" ++ contents ++ "</p>"
109+ then "<p>" ++ contents ++ "</p>"
110110 else contents ++ if null listLevel then "\n" else ""
111111
112112blockToTextile _ (RawHtml str) = return str
@@ -126,14 +126,14 @@ blockToTextile _ (CodeBlock (_,classes,_) str) | any (all isSpace) (lines str) =
126126 else " class=\"" ++ unwords classes ++ "\""
127127
128128blockToTextile _ (CodeBlock (_,classes,_) str) =
129− return $ "bc" ++ classes' ++ ". " ++ str ++ "\n"
129+ return $ "bc" ++ classes' ++ ". " ++ str ++ "\n\n"
130130 where classes' = if null classes
131131 then ""
132132 else "(" ++ unwords classes ++ ")"
133133
134134blockToTextile opts (BlockQuote bs@[Para _]) = do
135135 contents <- blockListToTextile opts bs
136− return $ "bq. " ++ contents
136+ return $ "bq. " ++ contents ++ "\n\n"
137137
138138blockToTextile opts (BlockQuote blocks) = do
139139 contents <- blockListToTextile opts blocks
@@ -155,20 +155,20 @@ blockToTextile opts (Table capt aligns widths headers rows') = do
155155 then return ""
156156 else do
157157 c <- inlineListToTextile opts capt
158− return $ " <caption>" ++ c ++ "</caption>\n"
158+ return $ "<caption>" ++ c ++ "</caption>\n"
159159 let percent w = show (truncate (100*w) :: Integer) ++ "%"
160160 let coltags = if all (== 0.0) widths
161161 then ""
162162 else unlines $ map
163− (\w -> " <col width=\"" ++ percent w ++ "\" />") widths
163+ (\w -> "<col width=\"" ++ percent w ++ "\" />") widths
164164 head' <- if all null headers
165165 then return ""
166166 else do
167167 hs <- tableRowToTextile opts alignStrings 0 headers
168− return $ " <thead>\n" ++ hs ++ "\n </thead>\n"
168+ return $ "<thead>\n" ++ hs ++ "\n</thead>\n"
169169 body' <- zipWithM (tableRowToTextile opts alignStrings) [1..] rows'
170− return $ " <table>\n" ++ captionDoc ++ coltags ++ head' ++
171− " <tbody>\n" ++ unlines body' ++ " </tbody>\n </table>\n"
170+ return $ "<table>\n" ++ captionDoc ++ coltags ++ head' ++
171+ "<tbody>\n" ++ unlines body' ++ "</tbody>\n</table>\n"
172172
173173blockToTextile opts x@(BulletList items) = do
174174 oldUseTags <- liftM stUseTags get
@@ -176,7 +176,7 @@ blockToTextile opts x@(BulletList items) = do
176176 if useTags
177177 then do
178178 contents <- withUseTags $ mapM (listItemToTextile opts) items
179− return $ " <ul>\n" ++ vcat contents ++ " </ul>\n"
179+ return $ "<ul>\n" ++ vcat contents ++ "\n</ul>\n"
180180 else do
181181 modify $ \s -> s { stListLevel = stListLevel s ++ "*" }
182182 level <- get >>= return . length . stListLevel
@@ -190,8 +190,8 @@ blockToTextile opts x@(OrderedList attribs items) = do
190190 if useTags
191191 then do
192192 contents <- withUseTags $ mapM (listItemToTextile opts) items
193− return $ " <ol" ++ listAttribsToString attribs ++ ">\n" ++ vcat contents ++
194− " </ol>\n"
193+ return $ "<ol" ++ listAttribsToString attribs ++ ">\n" ++ vcat contents ++
194+ "\n</ol>\n"
195195 else do
196196 modify $ \s -> s { stListLevel = stListLevel s ++ "#" }
197197 level <- get >>= return . length . stListLevel
@@ -201,7 +201,7 @@ blockToTextile opts x@(OrderedList attribs items) = do
201201
202202blockToTextile opts (DefinitionList items) = do
203203 contents <- withUseTags $ mapM (definitionListItemToTextile opts) items
204− return $ " <dl>\n" ++ vcat contents ++ " </dl>\n"
204+ return $ "<dl>\n" ++ vcat contents ++ "\n</dl>\n"
205205
206206-- Auxiliary functions for lists:
207207
@@ -222,7 +222,7 @@ listItemToTextile opts items = do
222222 contents <- blockListToTextile opts items
223223 useTags <- get >>= return . stUseTags
224224 if useTags
225− then return $ " <li>" ++ contents ++ "</li>"
225+ then return $ "<li>" ++ contents ++ "</li>"
226226 else do
227227 marker <- get >>= return . stListLevel
228228 return $ marker ++ " " ++ contents
@@ -234,8 +234,8 @@ definitionListItemToTextile :: WriterOptions
234234definitionListItemToTextile opts (label, items) = do
235235 labelText <- inlineListToTextile opts label
236236 contents <- mapM (blockListToTextile opts) items
237− return $ " <dt>" ++ labelText ++ "</dt>\n" ++
238− (intercalate "\n" $ map (\d -> " <dd>" ++ d ++ "</dd>") contents)
237+ return $ "<dt>" ++ labelText ++ "</dt>\n" ++
238+ (intercalate "\n" $ map (\d -> "<dd>" ++ d ++ "</dd>") contents)
239239
240240-- | True if the list can be handled by simple wiki markup, False if HTML tags will be needed.
241241isSimpleList :: Block -> Bool
tests/tables.textile+53−53
@@ -1,16 +1,16 @@
11Simple table with caption:
22
3− <table>
4− <caption>Demonstration of simple table syntax.</caption>
5− <thead>
3+<table>
4+<caption>Demonstration of simple table syntax.</caption>
5+<thead>
66<tr class="header">
77<th align="right">Right</th>
88<th align="left">Left</th>
99<th align="center">Center</th>
1010<th align="left">Default</th>
1111</tr>
12− </thead>
13− <tbody>
12+</thead>
13+<tbody>
1414<tr class="odd">
1515<td align="right">12</td>
1616<td align="left">12</td>
@@ -29,21 +29,21 @@ Simple table with caption:
2929<td align="center">1</td>
3030<td align="left">1</td>
3131</tr>
32− </tbody>
33− </table>
32+</tbody>
33+</table>
3434
3535Simple table without caption:
3636
37− <table>
38− <thead>
37+<table>
38+<thead>
3939<tr class="header">
4040<th align="right">Right</th>
4141<th align="left">Left</th>
4242<th align="center">Center</th>
4343<th align="left">Default</th>
4444</tr>
45− </thead>
46− <tbody>
45+</thead>
46+<tbody>
4747<tr class="odd">
4848<td align="right">12</td>
4949<td align="left">12</td>
@@ -62,22 +62,22 @@ Simple table without caption:
6262<td align="center">1</td>
6363<td align="left">1</td>
6464</tr>
65− </tbody>
66− </table>
65+</tbody>
66+</table>
6767
6868Simple table indented two spaces:
6969
70− <table>
71− <caption>Demonstration of simple table syntax.</caption>
72− <thead>
70+<table>
71+<caption>Demonstration of simple table syntax.</caption>
72+<thead>
7373<tr class="header">
7474<th align="right">Right</th>
7575<th align="left">Left</th>
7676<th align="center">Center</th>
7777<th align="left">Default</th>
7878</tr>
79− </thead>
80− <tbody>
79+</thead>
80+<tbody>
8181<tr class="odd">
8282<td align="right">12</td>
8383<td align="left">12</td>
@@ -96,26 +96,26 @@ Simple table indented two spaces:
9696<td align="center">1</td>
9797<td align="left">1</td>
9898</tr>
99− </tbody>
100− </table>
99+</tbody>
100+</table>
101101
102102Multiline table with caption:
103103
104− <table>
105− <caption>Here's the caption. It may span multiple lines.</caption>
106− <col width="15%" />
107− <col width="13%" />
108− <col width="16%" />
109− <col width="33%" />
110− <thead>
104+<table>
105+<caption>Here's the caption. It may span multiple lines.</caption>
106+<col width="15%" />
107+<col width="13%" />
108+<col width="16%" />
109+<col width="33%" />
110+<thead>
111111<tr class="header">
112112<th align="center">Centered Header</th>
113113<th align="left">Left Aligned</th>
114114<th align="right">Right Aligned</th>
115115<th align="left">Default aligned</th>
116116</tr>
117− </thead>
118− <tbody>
117+</thead>
118+<tbody>
119119<tr class="odd">
120120<td align="center">First</td>
121121<td align="left">row</td>
@@ -128,25 +128,25 @@ Multiline table with caption:
128128<td align="right">5.0</td>
129129<td align="left">Here's another one. Note the blank line between rows.</td>
130130</tr>
131− </tbody>
132− </table>
131+</tbody>
132+</table>
133133
134134Multiline table without caption:
135135
136− <table>
137− <col width="15%" />
138− <col width="13%" />
139− <col width="16%" />
140− <col width="33%" />
141− <thead>
136+<table>
137+<col width="15%" />
138+<col width="13%" />
139+<col width="16%" />
140+<col width="33%" />
141+<thead>
142142<tr class="header">
143143<th align="center">Centered Header</th>
144144<th align="left">Left Aligned</th>
145145<th align="right">Right Aligned</th>
146146<th align="left">Default aligned</th>
147147</tr>
148− </thead>
149− <tbody>
148+</thead>
149+<tbody>
150150<tr class="odd">
151151<td align="center">First</td>
152152<td align="left">row</td>
@@ -159,13 +159,13 @@ Multiline table without caption:
159159<td align="right">5.0</td>
160160<td align="left">Here's another one. Note the blank line between rows.</td>
161161</tr>
162− </tbody>
163− </table>
162+</tbody>
163+</table>
164164
165165Table without column headers:
166166
167− <table>
168− <tbody>
167+<table>
168+<tbody>
169169<tr class="odd">
170170<td align="right">12</td>
171171<td align="left">12</td>
@@ -184,17 +184,17 @@ Table without column headers:
184184<td align="center">1</td>
185185<td align="right">1</td>
186186</tr>
187− </tbody>
188− </table>
187+</tbody>
188+</table>
189189
190190Multiline table without column headers:
191191
192− <table>
193− <col width="15%" />
194− <col width="13%" />
195− <col width="16%" />
196− <col width="33%" />
197− <tbody>
192+<table>
193+<col width="15%" />
194+<col width="13%" />
195+<col width="16%" />
196+<col width="33%" />
197+<tbody>
198198<tr class="odd">
199199<td align="center">First</td>
200200<td align="left">row</td>
@@ -207,6 +207,6 @@ Multiline table without column headers:
207207<td align="right">5.0</td>
208208<td align="left">Here's another one. Note the blank line between rows.</td>
209209</tr>
210− </tbody>
211− </table>
210+</tbody>
211+</table>
212212
tests/writer.textile+104−80
@@ -45,6 +45,8 @@ E-mail style:
4545
4646bq. This is a block quote. It is pretty short.
4747
48+
49+
4850<blockquote>
4951
5052Code in a block quote:
@@ -62,8 +64,10 @@ Nested block quotes:
6264
6365bq. nested
6466
67+
6568bq. nested
6669
70+
6771</blockquote>
6872
6973This should not be a block quote: 2 &gt; 1.
@@ -164,11 +168,12 @@ and using spaces:
164168
165169Multiple paragraphs:
166170
167− <ol style="list-style-type: decimal;">
168− <li> <p>Item 1, graf one.</p>
169− <p>Item 1. graf two. The quick brown fox jumped over the lazy dog's back.</p></li>
170− <li> <p>Item 2.</p></li>
171− <li> <p>Item 3.</p></li> </ol>
171+<ol style="list-style-type: decimal;">
172+<li><p>Item 1, graf one.</p>
173+<p>Item 1. graf two. The quick brown fox jumped over the lazy dog's back.</p></li>
174+<li><p>Item 2.</p></li>
175+<li><p>Item 3.</p></li>
176+</ol>
172177
173178h2. Nested
174179
@@ -203,32 +208,39 @@ h2. Tabs and spaces
203208
204209h2. Fancy list markers
205210
206− <ol start="2" style="list-style-type: decimal;">
207− <li>begins with 2</li>
208− <li> <p>and now 3</p>
209− <p>with a continuation</p>
210− <ol start="4" style="list-style-type: lower-roman;">
211− <li>sublist with roman numerals, starting with 4</li>
212− <li>more items
213− <ol style="list-style-type: upper-alpha;">
214− <li>a subsublist</li>
215− <li>a subsublist</li> </ol>
216−</li> </ol>
217−</li> </ol>
211+<ol start="2" style="list-style-type: decimal;">
212+<li>begins with 2</li>
213+<li><p>and now 3</p>
214+<p>with a continuation</p>
215+<ol start="4" style="list-style-type: lower-roman;">
216+<li>sublist with roman numerals, starting with 4</li>
217+<li>more items
218+<ol style="list-style-type: upper-alpha;">
219+<li>a subsublist</li>
220+<li>a subsublist</li>
221+</ol>
222+</li>
223+</ol>
224+</li>
225+</ol>
218226
219227Nesting:
220228
221− <ol style="list-style-type: upper-alpha;">
222− <li>Upper Alpha
223− <ol style="list-style-type: upper-roman;">
224− <li>Upper Roman.
225− <ol start="6" style="list-style-type: decimal;">
226− <li>Decimal start with 6
227− <ol start="3" style="list-style-type: lower-alpha;">
228− <li>Lower alpha with paren</li> </ol>
229−</li> </ol>
230−</li> </ol>
231−</li> </ol>
229+<ol style="list-style-type: upper-alpha;">
230+<li>Upper Alpha
231+<ol style="list-style-type: upper-roman;">
232+<li>Upper Roman.
233+<ol start="6" style="list-style-type: decimal;">
234+<li>Decimal start with 6
235+<ol start="3" style="list-style-type: lower-alpha;">
236+<li>Lower alpha with paren</li>
237+</ol>
238+</li>
239+</ol>
240+</li>
241+</ol>
242+</li>
243+</ol>
232244
233245Autonumbering:
234246
@@ -248,78 +260,88 @@ h1. Definition Lists
248260
249261Tight using spaces:
250262
251− <dl>
252− <dt>apple</dt>
253− <dd>red fruit</dd>
254− <dt>orange</dt>
255− <dd>orange fruit</dd>
256− <dt>banana</dt>
257− <dd>yellow fruit</dd> </dl>
263+<dl>
264+<dt>apple</dt>
265+<dd>red fruit</dd>
266+<dt>orange</dt>
267+<dd>orange fruit</dd>
268+<dt>banana</dt>
269+<dd>yellow fruit</dd>
270+</dl>
258271
259272Tight using tabs:
260273
261− <dl>
262− <dt>apple</dt>
263− <dd>red fruit</dd>
264− <dt>orange</dt>
265− <dd>orange fruit</dd>
266− <dt>banana</dt>
267− <dd>yellow fruit</dd> </dl>
274+<dl>
275+<dt>apple</dt>
276+<dd>red fruit</dd>
277+<dt>orange</dt>
278+<dd>orange fruit</dd>
279+<dt>banana</dt>
280+<dd>yellow fruit</dd>
281+</dl>
268282
269283Loose:
270284
271− <dl>
272− <dt>apple</dt>
273− <dd> <p>red fruit</p></dd>
274− <dt>orange</dt>
275− <dd> <p>orange fruit</p></dd>
276− <dt>banana</dt>
277− <dd> <p>yellow fruit</p></dd> </dl>
285+<dl>
286+<dt>apple</dt>
287+<dd><p>red fruit</p></dd>
288+<dt>orange</dt>
289+<dd><p>orange fruit</p></dd>
290+<dt>banana</dt>
291+<dd><p>yellow fruit</p></dd>
292+</dl>
278293
279294Multiple blocks with italics:
280295
281− <dl>
282− <dt>_apple_</dt>
283− <dd> <p>red fruit</p>
284− <p>contains seeds, crisp, pleasant to taste</p></dd>
285− <dt>_orange_</dt>
286− <dd> <p>orange fruit</p>
296+<dl>
297+<dt>_apple_</dt>
298+<dd><p>red fruit</p>
299+<p>contains seeds, crisp, pleasant to taste</p></dd>
300+<dt>_orange_</dt>
301+<dd><p>orange fruit</p>
287302bc. { orange code block }
288303
289−bq. <p>orange block quote</p></dd> </dl>
304+bq. <p>orange block quote</p>
305+
306+</dd>
307+</dl>
290308
291309Multiple definitions, tight:
292310
293− <dl>
294− <dt>apple</dt>
295− <dd>red fruit</dd>
296− <dd>computer</dd>
297− <dt>orange</dt>
298− <dd>orange fruit</dd>
299− <dd>bank</dd> </dl>
311+<dl>
312+<dt>apple</dt>
313+<dd>red fruit</dd>
314+<dd>computer</dd>
315+<dt>orange</dt>
316+<dd>orange fruit</dd>
317+<dd>bank</dd>
318+</dl>
300319
301320Multiple definitions, loose:
302321
303− <dl>
304− <dt>apple</dt>
305− <dd> <p>red fruit</p></dd>
306− <dd> <p>computer</p></dd>
307− <dt>orange</dt>
308− <dd> <p>orange fruit</p></dd>
309− <dd> <p>bank</p></dd> </dl>
322+<dl>
323+<dt>apple</dt>
324+<dd><p>red fruit</p></dd>
325+<dd><p>computer</p></dd>
326+<dt>orange</dt>
327+<dd><p>orange fruit</p></dd>
328+<dd><p>bank</p></dd>
329+</dl>
310330
311331Blank line after term, indented marker, alternate markers:
312332
313− <dl>
314− <dt>apple</dt>
315− <dd> <p>red fruit</p></dd>
316− <dd> <p>computer</p></dd>
317− <dt>orange</dt>
318− <dd> <p>orange fruit</p>
319− <ol style="list-style-type: decimal;">
320− <li>sublist</li>
321− <li>sublist</li> </ol>
322−</dd> </dl>
333+<dl>
334+<dt>apple</dt>
335+<dd><p>red fruit</p></dd>
336+<dd><p>computer</p></dd>
337+<dt>orange</dt>
338+<dd><p>orange fruit</p>
339+<ol style="list-style-type: decimal;">
340+<li>sublist</li>
341+<li>sublist</li>
342+</ol>
343+</dd>
344+</dl>
323345
324346h1. HTML Blocks
325347
@@ -630,6 +652,7 @@ An e-mail address: "nobody@nowhere.net":mailto:nobody@nowhere.net
630652
631653bq. Blockquoted: "http://example.com/":http://example.com/
632654
655+
633656Auto-links should not occur here: @<http://example.com/>@
634657
635658bc. or here: <http://example.com/>
@@ -653,6 +676,7 @@ Here is a footnote reference,[1] and another.[2] This should _not_ be a footnote
653676
654677bq. Notes can go in quotes.[4]
655678
679+
656680# And in list items.[5]
657681
658682This paragraph should not be part of the note, as it is not indented.