parent
df23d96c89
commit
57cba3f1d5
4 changed files with 52 additions and 8 deletions
|
@ -61,6 +61,10 @@ headerStart = try $
|
|||
tableStart :: Monad m => OrgParser m Char
|
||||
tableStart = try $ skipSpaces *> char '|'
|
||||
|
||||
gridTableStart :: Monad m => OrgParser m ()
|
||||
gridTableStart = try $ skipSpaces <* char '+' <* char '-'
|
||||
|
||||
|
||||
latexEnvStart :: Monad m => OrgParser m String
|
||||
latexEnvStart = try $ do
|
||||
skipSpaces *> string "\\begin{"
|
||||
|
@ -126,6 +130,7 @@ endOfBlock = lookAhead . try $ do
|
|||
, hline
|
||||
, metaLineStart
|
||||
, commentLineStart
|
||||
, gridTableStart
|
||||
, void noteMarker
|
||||
, void tableStart
|
||||
, void drawerStart
|
||||
|
|
|
@ -755,7 +755,11 @@ data OrgTable = OrgTable
|
|||
}
|
||||
|
||||
table :: PandocMonad m => OrgParser m (F Blocks)
|
||||
table = try $ do
|
||||
table = gridTableWith blocks True <|> orgTable
|
||||
|
||||
-- | A normal org table
|
||||
orgTable :: PandocMonad m => OrgParser m (F Blocks)
|
||||
orgTable = try $ do
|
||||
-- don't allow a table on the first line of a list item; org requires that
|
||||
-- tables start at first non-space character on the line
|
||||
let isFirstInListItem st = (orgStateParserContext st == ListItemState) &&
|
||||
|
@ -854,28 +858,28 @@ normalizeTable (OrgTable colProps heads rows) =
|
|||
rowToContent :: OrgTable
|
||||
-> OrgTableRow
|
||||
-> F OrgTable
|
||||
rowToContent orgTable row =
|
||||
rowToContent tbl row =
|
||||
case row of
|
||||
OrgHlineRow -> return singleRowPromotedToHeader
|
||||
OrgAlignRow props -> return . setProperties $ props
|
||||
OrgContentRow cs -> appendToBody cs
|
||||
where
|
||||
singleRowPromotedToHeader :: OrgTable
|
||||
singleRowPromotedToHeader = case orgTable of
|
||||
singleRowPromotedToHeader = case tbl of
|
||||
OrgTable{ orgTableHeader = [], orgTableRows = b:[] } ->
|
||||
orgTable{ orgTableHeader = b , orgTableRows = [] }
|
||||
_ -> orgTable
|
||||
tbl{ orgTableHeader = b , orgTableRows = [] }
|
||||
_ -> tbl
|
||||
|
||||
setProperties :: [ColumnProperty] -> OrgTable
|
||||
setProperties ps = orgTable{ orgTableColumnProperties = ps }
|
||||
setProperties ps = tbl{ orgTableColumnProperties = ps }
|
||||
|
||||
appendToBody :: F [Blocks] -> F OrgTable
|
||||
appendToBody frow = do
|
||||
newRow <- frow
|
||||
let oldRows = orgTableRows orgTable
|
||||
let oldRows = orgTableRows tbl
|
||||
-- NOTE: This is an inefficient O(n) operation. This should be changed
|
||||
-- if performance ever becomes a problem.
|
||||
return orgTable{ orgTableRows = oldRows ++ [newRow] }
|
||||
return tbl{ orgTableRows = oldRows ++ [newRow] }
|
||||
|
||||
|
||||
--
|
||||
|
|
|
@ -70,6 +70,7 @@ module Text.Pandoc.Readers.Org.Parsing
|
|||
, dash
|
||||
, ellipses
|
||||
, citeKey
|
||||
, gridTableWith
|
||||
-- * Re-exports from Text.Pandoc.Parsec
|
||||
, runParser
|
||||
, runParserT
|
||||
|
|
34
test/command/3314.md
Normal file
34
test/command/3314.md
Normal file
|
@ -0,0 +1,34 @@
|
|||
See #3315 and <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#simple-tables>.
|
||||
|
||||
```
|
||||
% pandoc -f org -t html5
|
||||
+-----------+-------+----------+
|
||||
| First | 12.0 | Example |
|
||||
| | | row |
|
||||
| | | spanning |
|
||||
| | | lines |
|
||||
+-----------+-------+----------+
|
||||
| Second | 5.0 | Another |
|
||||
+-----------+-------+----------+
|
||||
^D
|
||||
<table style="width:43%;">
|
||||
<colgroup>
|
||||
<col style="width: 16%" />
|
||||
<col style="width: 11%" />
|
||||
<col style="width: 15%" />
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td>First</td>
|
||||
<td>12.0</td>
|
||||
<td>Example row spanning lines</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td>Second</td>
|
||||
<td>5.0</td>
|
||||
<td>Another</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
```
|
||||
|
Loading…
Reference in a new issue