Added needed space after .bc and .bq.
Otherwise these can trap a </dd>, for example. Better solution to try next: rewrite using Pretty.
This commit is contained in:
parent
16d4366431
commit
65a015e74b
3 changed files with 172 additions and 148 deletions
|
@ -106,7 +106,7 @@ blockToTextile opts (Para inlines) = do
|
|||
listLevel <- liftM stListLevel get
|
||||
contents <- inlineListToTextile opts inlines
|
||||
return $ if useTags
|
||||
then " <p>" ++ contents ++ "</p>"
|
||||
then "<p>" ++ contents ++ "</p>"
|
||||
else contents ++ if null listLevel then "\n" else ""
|
||||
|
||||
blockToTextile _ (RawHtml str) = return str
|
||||
|
@ -126,14 +126,14 @@ blockToTextile _ (CodeBlock (_,classes,_) str) | any (all isSpace) (lines str) =
|
|||
else " class=\"" ++ unwords classes ++ "\""
|
||||
|
||||
blockToTextile _ (CodeBlock (_,classes,_) str) =
|
||||
return $ "bc" ++ classes' ++ ". " ++ str ++ "\n"
|
||||
return $ "bc" ++ classes' ++ ". " ++ str ++ "\n\n"
|
||||
where classes' = if null classes
|
||||
then ""
|
||||
else "(" ++ unwords classes ++ ")"
|
||||
|
||||
blockToTextile opts (BlockQuote bs@[Para _]) = do
|
||||
contents <- blockListToTextile opts bs
|
||||
return $ "bq. " ++ contents
|
||||
return $ "bq. " ++ contents ++ "\n\n"
|
||||
|
||||
blockToTextile opts (BlockQuote blocks) = do
|
||||
contents <- blockListToTextile opts blocks
|
||||
|
@ -155,20 +155,20 @@ blockToTextile opts (Table capt aligns widths headers rows') = do
|
|||
then return ""
|
||||
else do
|
||||
c <- inlineListToTextile opts capt
|
||||
return $ " <caption>" ++ c ++ "</caption>\n"
|
||||
return $ "<caption>" ++ c ++ "</caption>\n"
|
||||
let percent w = show (truncate (100*w) :: Integer) ++ "%"
|
||||
let coltags = if all (== 0.0) widths
|
||||
then ""
|
||||
else unlines $ map
|
||||
(\w -> " <col width=\"" ++ percent w ++ "\" />") widths
|
||||
(\w -> "<col width=\"" ++ percent w ++ "\" />") widths
|
||||
head' <- if all null headers
|
||||
then return ""
|
||||
else do
|
||||
hs <- tableRowToTextile opts alignStrings 0 headers
|
||||
return $ " <thead>\n" ++ hs ++ "\n </thead>\n"
|
||||
return $ "<thead>\n" ++ hs ++ "\n</thead>\n"
|
||||
body' <- zipWithM (tableRowToTextile opts alignStrings) [1..] rows'
|
||||
return $ " <table>\n" ++ captionDoc ++ coltags ++ head' ++
|
||||
" <tbody>\n" ++ unlines body' ++ " </tbody>\n </table>\n"
|
||||
return $ "<table>\n" ++ captionDoc ++ coltags ++ head' ++
|
||||
"<tbody>\n" ++ unlines body' ++ "</tbody>\n</table>\n"
|
||||
|
||||
blockToTextile opts x@(BulletList items) = do
|
||||
oldUseTags <- liftM stUseTags get
|
||||
|
@ -176,7 +176,7 @@ blockToTextile opts x@(BulletList items) = do
|
|||
if useTags
|
||||
then do
|
||||
contents <- withUseTags $ mapM (listItemToTextile opts) items
|
||||
return $ " <ul>\n" ++ vcat contents ++ " </ul>\n"
|
||||
return $ "<ul>\n" ++ vcat contents ++ "\n</ul>\n"
|
||||
else do
|
||||
modify $ \s -> s { stListLevel = stListLevel s ++ "*" }
|
||||
level <- get >>= return . length . stListLevel
|
||||
|
@ -190,8 +190,8 @@ blockToTextile opts x@(OrderedList attribs items) = do
|
|||
if useTags
|
||||
then do
|
||||
contents <- withUseTags $ mapM (listItemToTextile opts) items
|
||||
return $ " <ol" ++ listAttribsToString attribs ++ ">\n" ++ vcat contents ++
|
||||
" </ol>\n"
|
||||
return $ "<ol" ++ listAttribsToString attribs ++ ">\n" ++ vcat contents ++
|
||||
"\n</ol>\n"
|
||||
else do
|
||||
modify $ \s -> s { stListLevel = stListLevel s ++ "#" }
|
||||
level <- get >>= return . length . stListLevel
|
||||
|
@ -201,7 +201,7 @@ blockToTextile opts x@(OrderedList attribs items) = do
|
|||
|
||||
blockToTextile opts (DefinitionList items) = do
|
||||
contents <- withUseTags $ mapM (definitionListItemToTextile opts) items
|
||||
return $ " <dl>\n" ++ vcat contents ++ " </dl>\n"
|
||||
return $ "<dl>\n" ++ vcat contents ++ "\n</dl>\n"
|
||||
|
||||
-- Auxiliary functions for lists:
|
||||
|
||||
|
@ -222,7 +222,7 @@ listItemToTextile opts items = do
|
|||
contents <- blockListToTextile opts items
|
||||
useTags <- get >>= return . stUseTags
|
||||
if useTags
|
||||
then return $ " <li>" ++ contents ++ "</li>"
|
||||
then return $ "<li>" ++ contents ++ "</li>"
|
||||
else do
|
||||
marker <- get >>= return . stListLevel
|
||||
return $ marker ++ " " ++ contents
|
||||
|
@ -234,8 +234,8 @@ definitionListItemToTextile :: WriterOptions
|
|||
definitionListItemToTextile opts (label, items) = do
|
||||
labelText <- inlineListToTextile opts label
|
||||
contents <- mapM (blockListToTextile opts) items
|
||||
return $ " <dt>" ++ labelText ++ "</dt>\n" ++
|
||||
(intercalate "\n" $ map (\d -> " <dd>" ++ d ++ "</dd>") contents)
|
||||
return $ "<dt>" ++ labelText ++ "</dt>\n" ++
|
||||
(intercalate "\n" $ map (\d -> "<dd>" ++ d ++ "</dd>") contents)
|
||||
|
||||
-- | True if the list can be handled by simple wiki markup, False if HTML tags will be needed.
|
||||
isSimpleList :: Block -> Bool
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
Simple table with caption:
|
||||
|
||||
<table>
|
||||
<caption>Demonstration of simple table syntax.</caption>
|
||||
<thead>
|
||||
<table>
|
||||
<caption>Demonstration of simple table syntax.</caption>
|
||||
<thead>
|
||||
<tr class="header">
|
||||
<th align="right">Right</th>
|
||||
<th align="left">Left</th>
|
||||
<th align="center">Center</th>
|
||||
<th align="left">Default</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="right">12</td>
|
||||
<td align="left">12</td>
|
||||
|
@ -29,21 +29,21 @@ Simple table with caption:
|
|||
<td align="center">1</td>
|
||||
<td align="left">1</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Simple table without caption:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<table>
|
||||
<thead>
|
||||
<tr class="header">
|
||||
<th align="right">Right</th>
|
||||
<th align="left">Left</th>
|
||||
<th align="center">Center</th>
|
||||
<th align="left">Default</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="right">12</td>
|
||||
<td align="left">12</td>
|
||||
|
@ -62,22 +62,22 @@ Simple table without caption:
|
|||
<td align="center">1</td>
|
||||
<td align="left">1</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Simple table indented two spaces:
|
||||
|
||||
<table>
|
||||
<caption>Demonstration of simple table syntax.</caption>
|
||||
<thead>
|
||||
<table>
|
||||
<caption>Demonstration of simple table syntax.</caption>
|
||||
<thead>
|
||||
<tr class="header">
|
||||
<th align="right">Right</th>
|
||||
<th align="left">Left</th>
|
||||
<th align="center">Center</th>
|
||||
<th align="left">Default</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="right">12</td>
|
||||
<td align="left">12</td>
|
||||
|
@ -96,26 +96,26 @@ Simple table indented two spaces:
|
|||
<td align="center">1</td>
|
||||
<td align="left">1</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Multiline table with caption:
|
||||
|
||||
<table>
|
||||
<caption>Here's the caption. It may span multiple lines.</caption>
|
||||
<col width="15%" />
|
||||
<col width="13%" />
|
||||
<col width="16%" />
|
||||
<col width="33%" />
|
||||
<thead>
|
||||
<table>
|
||||
<caption>Here's the caption. It may span multiple lines.</caption>
|
||||
<col width="15%" />
|
||||
<col width="13%" />
|
||||
<col width="16%" />
|
||||
<col width="33%" />
|
||||
<thead>
|
||||
<tr class="header">
|
||||
<th align="center">Centered Header</th>
|
||||
<th align="left">Left Aligned</th>
|
||||
<th align="right">Right Aligned</th>
|
||||
<th align="left">Default aligned</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="center">First</td>
|
||||
<td align="left">row</td>
|
||||
|
@ -128,25 +128,25 @@ Multiline table with caption:
|
|||
<td align="right">5.0</td>
|
||||
<td align="left">Here's another one. Note the blank line between rows.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Multiline table without caption:
|
||||
|
||||
<table>
|
||||
<col width="15%" />
|
||||
<col width="13%" />
|
||||
<col width="16%" />
|
||||
<col width="33%" />
|
||||
<thead>
|
||||
<table>
|
||||
<col width="15%" />
|
||||
<col width="13%" />
|
||||
<col width="16%" />
|
||||
<col width="33%" />
|
||||
<thead>
|
||||
<tr class="header">
|
||||
<th align="center">Centered Header</th>
|
||||
<th align="left">Left Aligned</th>
|
||||
<th align="right">Right Aligned</th>
|
||||
<th align="left">Default aligned</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="center">First</td>
|
||||
<td align="left">row</td>
|
||||
|
@ -159,13 +159,13 @@ Multiline table without caption:
|
|||
<td align="right">5.0</td>
|
||||
<td align="left">Here's another one. Note the blank line between rows.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Table without column headers:
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="right">12</td>
|
||||
<td align="left">12</td>
|
||||
|
@ -184,17 +184,17 @@ Table without column headers:
|
|||
<td align="center">1</td>
|
||||
<td align="right">1</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Multiline table without column headers:
|
||||
|
||||
<table>
|
||||
<col width="15%" />
|
||||
<col width="13%" />
|
||||
<col width="16%" />
|
||||
<col width="33%" />
|
||||
<tbody>
|
||||
<table>
|
||||
<col width="15%" />
|
||||
<col width="13%" />
|
||||
<col width="16%" />
|
||||
<col width="33%" />
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="center">First</td>
|
||||
<td align="left">row</td>
|
||||
|
@ -207,6 +207,6 @@ Multiline table without column headers:
|
|||
<td align="right">5.0</td>
|
||||
<td align="left">Here's another one. Note the blank line between rows.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
|
|
@ -45,6 +45,8 @@ E-mail style:
|
|||
|
||||
bq. This is a block quote. It is pretty short.
|
||||
|
||||
|
||||
|
||||
<blockquote>
|
||||
|
||||
Code in a block quote:
|
||||
|
@ -62,8 +64,10 @@ Nested block quotes:
|
|||
|
||||
bq. nested
|
||||
|
||||
|
||||
bq. nested
|
||||
|
||||
|
||||
</blockquote>
|
||||
|
||||
This should not be a block quote: 2 > 1.
|
||||
|
@ -164,11 +168,12 @@ and using spaces:
|
|||
|
||||
Multiple paragraphs:
|
||||
|
||||
<ol style="list-style-type: decimal;">
|
||||
<li> <p>Item 1, graf one.</p>
|
||||
<p>Item 1. graf two. The quick brown fox jumped over the lazy dog's back.</p></li>
|
||||
<li> <p>Item 2.</p></li>
|
||||
<li> <p>Item 3.</p></li> </ol>
|
||||
<ol style="list-style-type: decimal;">
|
||||
<li><p>Item 1, graf one.</p>
|
||||
<p>Item 1. graf two. The quick brown fox jumped over the lazy dog's back.</p></li>
|
||||
<li><p>Item 2.</p></li>
|
||||
<li><p>Item 3.</p></li>
|
||||
</ol>
|
||||
|
||||
h2. Nested
|
||||
|
||||
|
@ -203,32 +208,39 @@ h2. Tabs and spaces
|
|||
|
||||
h2. Fancy list markers
|
||||
|
||||
<ol start="2" style="list-style-type: decimal;">
|
||||
<li>begins with 2</li>
|
||||
<li> <p>and now 3</p>
|
||||
<p>with a continuation</p>
|
||||
<ol start="4" style="list-style-type: lower-roman;">
|
||||
<li>sublist with roman numerals, starting with 4</li>
|
||||
<li>more items
|
||||
<ol style="list-style-type: upper-alpha;">
|
||||
<li>a subsublist</li>
|
||||
<li>a subsublist</li> </ol>
|
||||
</li> </ol>
|
||||
</li> </ol>
|
||||
<ol start="2" style="list-style-type: decimal;">
|
||||
<li>begins with 2</li>
|
||||
<li><p>and now 3</p>
|
||||
<p>with a continuation</p>
|
||||
<ol start="4" style="list-style-type: lower-roman;">
|
||||
<li>sublist with roman numerals, starting with 4</li>
|
||||
<li>more items
|
||||
<ol style="list-style-type: upper-alpha;">
|
||||
<li>a subsublist</li>
|
||||
<li>a subsublist</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
Nesting:
|
||||
|
||||
<ol style="list-style-type: upper-alpha;">
|
||||
<li>Upper Alpha
|
||||
<ol style="list-style-type: upper-roman;">
|
||||
<li>Upper Roman.
|
||||
<ol start="6" style="list-style-type: decimal;">
|
||||
<li>Decimal start with 6
|
||||
<ol start="3" style="list-style-type: lower-alpha;">
|
||||
<li>Lower alpha with paren</li> </ol>
|
||||
</li> </ol>
|
||||
</li> </ol>
|
||||
</li> </ol>
|
||||
<ol style="list-style-type: upper-alpha;">
|
||||
<li>Upper Alpha
|
||||
<ol style="list-style-type: upper-roman;">
|
||||
<li>Upper Roman.
|
||||
<ol start="6" style="list-style-type: decimal;">
|
||||
<li>Decimal start with 6
|
||||
<ol start="3" style="list-style-type: lower-alpha;">
|
||||
<li>Lower alpha with paren</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
Autonumbering:
|
||||
|
||||
|
@ -248,78 +260,88 @@ h1. Definition Lists
|
|||
|
||||
Tight using spaces:
|
||||
|
||||
<dl>
|
||||
<dt>apple</dt>
|
||||
<dd>red fruit</dd>
|
||||
<dt>orange</dt>
|
||||
<dd>orange fruit</dd>
|
||||
<dt>banana</dt>
|
||||
<dd>yellow fruit</dd> </dl>
|
||||
<dl>
|
||||
<dt>apple</dt>
|
||||
<dd>red fruit</dd>
|
||||
<dt>orange</dt>
|
||||
<dd>orange fruit</dd>
|
||||
<dt>banana</dt>
|
||||
<dd>yellow fruit</dd>
|
||||
</dl>
|
||||
|
||||
Tight using tabs:
|
||||
|
||||
<dl>
|
||||
<dt>apple</dt>
|
||||
<dd>red fruit</dd>
|
||||
<dt>orange</dt>
|
||||
<dd>orange fruit</dd>
|
||||
<dt>banana</dt>
|
||||
<dd>yellow fruit</dd> </dl>
|
||||
<dl>
|
||||
<dt>apple</dt>
|
||||
<dd>red fruit</dd>
|
||||
<dt>orange</dt>
|
||||
<dd>orange fruit</dd>
|
||||
<dt>banana</dt>
|
||||
<dd>yellow fruit</dd>
|
||||
</dl>
|
||||
|
||||
Loose:
|
||||
|
||||
<dl>
|
||||
<dt>apple</dt>
|
||||
<dd> <p>red fruit</p></dd>
|
||||
<dt>orange</dt>
|
||||
<dd> <p>orange fruit</p></dd>
|
||||
<dt>banana</dt>
|
||||
<dd> <p>yellow fruit</p></dd> </dl>
|
||||
<dl>
|
||||
<dt>apple</dt>
|
||||
<dd><p>red fruit</p></dd>
|
||||
<dt>orange</dt>
|
||||
<dd><p>orange fruit</p></dd>
|
||||
<dt>banana</dt>
|
||||
<dd><p>yellow fruit</p></dd>
|
||||
</dl>
|
||||
|
||||
Multiple blocks with italics:
|
||||
|
||||
<dl>
|
||||
<dt>_apple_</dt>
|
||||
<dd> <p>red fruit</p>
|
||||
<p>contains seeds, crisp, pleasant to taste</p></dd>
|
||||
<dt>_orange_</dt>
|
||||
<dd> <p>orange fruit</p>
|
||||
<dl>
|
||||
<dt>_apple_</dt>
|
||||
<dd><p>red fruit</p>
|
||||
<p>contains seeds, crisp, pleasant to taste</p></dd>
|
||||
<dt>_orange_</dt>
|
||||
<dd><p>orange fruit</p>
|
||||
bc. { orange code block }
|
||||
|
||||
bq. <p>orange block quote</p></dd> </dl>
|
||||
bq. <p>orange block quote</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
Multiple definitions, tight:
|
||||
|
||||
<dl>
|
||||
<dt>apple</dt>
|
||||
<dd>red fruit</dd>
|
||||
<dd>computer</dd>
|
||||
<dt>orange</dt>
|
||||
<dd>orange fruit</dd>
|
||||
<dd>bank</dd> </dl>
|
||||
<dl>
|
||||
<dt>apple</dt>
|
||||
<dd>red fruit</dd>
|
||||
<dd>computer</dd>
|
||||
<dt>orange</dt>
|
||||
<dd>orange fruit</dd>
|
||||
<dd>bank</dd>
|
||||
</dl>
|
||||
|
||||
Multiple definitions, loose:
|
||||
|
||||
<dl>
|
||||
<dt>apple</dt>
|
||||
<dd> <p>red fruit</p></dd>
|
||||
<dd> <p>computer</p></dd>
|
||||
<dt>orange</dt>
|
||||
<dd> <p>orange fruit</p></dd>
|
||||
<dd> <p>bank</p></dd> </dl>
|
||||
<dl>
|
||||
<dt>apple</dt>
|
||||
<dd><p>red fruit</p></dd>
|
||||
<dd><p>computer</p></dd>
|
||||
<dt>orange</dt>
|
||||
<dd><p>orange fruit</p></dd>
|
||||
<dd><p>bank</p></dd>
|
||||
</dl>
|
||||
|
||||
Blank line after term, indented marker, alternate markers:
|
||||
|
||||
<dl>
|
||||
<dt>apple</dt>
|
||||
<dd> <p>red fruit</p></dd>
|
||||
<dd> <p>computer</p></dd>
|
||||
<dt>orange</dt>
|
||||
<dd> <p>orange fruit</p>
|
||||
<ol style="list-style-type: decimal;">
|
||||
<li>sublist</li>
|
||||
<li>sublist</li> </ol>
|
||||
</dd> </dl>
|
||||
<dl>
|
||||
<dt>apple</dt>
|
||||
<dd><p>red fruit</p></dd>
|
||||
<dd><p>computer</p></dd>
|
||||
<dt>orange</dt>
|
||||
<dd><p>orange fruit</p>
|
||||
<ol style="list-style-type: decimal;">
|
||||
<li>sublist</li>
|
||||
<li>sublist</li>
|
||||
</ol>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
h1. HTML Blocks
|
||||
|
||||
|
@ -630,6 +652,7 @@ An e-mail address: "nobody@nowhere.net":mailto:nobody@nowhere.net
|
|||
|
||||
bq. Blockquoted: "http://example.com/":http://example.com/
|
||||
|
||||
|
||||
Auto-links should not occur here: @<http://example.com/>@
|
||||
|
||||
bc. or here: <http://example.com/>
|
||||
|
@ -653,6 +676,7 @@ Here is a footnote reference,[1] and another.[2] This should _not_ be a footnote
|
|||
|
||||
bq. Notes can go in quotes.[4]
|
||||
|
||||
|
||||
# And in list items.[5]
|
||||
|
||||
This paragraph should not be part of the note, as it is not indented.
|
||||
|
|
Loading…
Reference in a new issue