parent
62948f3579
commit
34151e8da8
5 changed files with 158 additions and 5 deletions
|
@ -919,7 +919,7 @@ tableToHtml opts (Ann.Table attr caption colspecs thead tbodies tfoot) = do
|
|||
nl opts
|
||||
coltags <- colSpecListToHtml opts colspecs
|
||||
head' <- tableHeadToHtml opts thead
|
||||
body' <- mconcat <$> mapM (tableBodyToHtml opts) tbodies
|
||||
bodies <- intersperse (nl opts) <$> mapM (tableBodyToHtml opts) tbodies
|
||||
foot' <- tableFootToHtml opts tfoot
|
||||
let (ident,classes,kvs) = attr
|
||||
-- When widths of columns are < 100%, we need to set width for the whole
|
||||
|
@ -940,7 +940,7 @@ tableToHtml opts (Ann.Table attr caption colspecs thead tbodies tfoot) = do
|
|||
captionDoc
|
||||
coltags
|
||||
head'
|
||||
body'
|
||||
mconcat bodies
|
||||
foot'
|
||||
nl opts
|
||||
|
||||
|
@ -948,8 +948,14 @@ tableBodyToHtml :: PandocMonad m
|
|||
=> WriterOptions
|
||||
-> Ann.TableBody
|
||||
-> StateT WriterState m Html
|
||||
tableBodyToHtml opts (Ann.TableBody attr _rowHeadCols _intm rows) =
|
||||
addAttrs opts attr . H.tbody =<< bodyRowsToHtml opts rows
|
||||
tableBodyToHtml opts (Ann.TableBody attr _rowHeadCols inthead rows) =
|
||||
addAttrs opts attr . H.tbody =<< do
|
||||
intermediateHead <-
|
||||
if null inthead
|
||||
then return mempty
|
||||
else headerRowsToHtml opts Thead inthead
|
||||
bodyRows <- bodyRowsToHtml opts rows
|
||||
return $ intermediateHead <> bodyRows
|
||||
|
||||
tableHeadToHtml :: PandocMonad m
|
||||
=> WriterOptions
|
||||
|
|
|
@ -272,7 +272,7 @@ extendedWriterTests pandocPath format
|
|||
opts
|
||||
("tables" </> name <.> "native")
|
||||
("tables" </> name <.> format)
|
||||
in map testForTable ["planets", "nordics"]
|
||||
in map testForTable ["planets", "nordics", "students"]
|
||||
where
|
||||
opts = ["-r", "native", "-w", format, "--columns=78",
|
||||
"--variable", "pandoc-version="]
|
||||
|
|
55
test/tables/students.html4
Normal file
55
test/tables/students.html4
Normal file
|
@ -0,0 +1,55 @@
|
|||
<table id="students" source="mdn">
|
||||
<caption><p>List of Students</p></caption>
|
||||
<colgroup>
|
||||
<col width="50%" />
|
||||
<col width="50%" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr class="header">
|
||||
<th align="center">Student ID</th>
|
||||
<th align="center">Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="souvereign-states">
|
||||
<tr class="odd">
|
||||
<th align="left" colspan="2">Computer Science</th>
|
||||
</tr>
|
||||
|
||||
<tr class="odd">
|
||||
<td align="left">3741255</td>
|
||||
<td align="left">Jones, Martha</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="left">4077830</td>
|
||||
<td align="left">Pierce, Benjamin</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="left">5151701</td>
|
||||
<td align="left">Kirk, James</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<th align="left" colspan="2">Russian Literature</th>
|
||||
</tr>
|
||||
|
||||
<tr class="odd">
|
||||
<td align="left">3971244</td>
|
||||
<td align="left">Nim, Victor</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<th align="left" colspan="2">Astrophysics</th>
|
||||
</tr>
|
||||
|
||||
<tr class="odd">
|
||||
<td align="left">4100332</td>
|
||||
<td align="left">Petrov, Alexandra</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="left">4100332</td>
|
||||
<td align="left">Toyota, Hiroko</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
55
test/tables/students.html5
Normal file
55
test/tables/students.html5
Normal file
|
@ -0,0 +1,55 @@
|
|||
<table id="students" data-source="mdn">
|
||||
<caption><p>List of Students</p></caption>
|
||||
<colgroup>
|
||||
<col style="width: 50%" />
|
||||
<col style="width: 50%" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr class="header">
|
||||
<th style="text-align: center;">Student ID</th>
|
||||
<th style="text-align: center;">Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="souvereign-states">
|
||||
<tr class="odd">
|
||||
<th style="text-align: left;" colspan="2">Computer Science</th>
|
||||
</tr>
|
||||
|
||||
<tr class="odd">
|
||||
<td style="text-align: left;">3741255</td>
|
||||
<td style="text-align: left;">Jones, Martha</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td style="text-align: left;">4077830</td>
|
||||
<td style="text-align: left;">Pierce, Benjamin</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td style="text-align: left;">5151701</td>
|
||||
<td style="text-align: left;">Kirk, James</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<th style="text-align: left;" colspan="2">Russian Literature</th>
|
||||
</tr>
|
||||
|
||||
<tr class="odd">
|
||||
<td style="text-align: left;">3971244</td>
|
||||
<td style="text-align: left;">Nim, Victor</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<th style="text-align: left;" colspan="2">Astrophysics</th>
|
||||
</tr>
|
||||
|
||||
<tr class="odd">
|
||||
<td style="text-align: left;">4100332</td>
|
||||
<td style="text-align: left;">Petrov, Alexandra</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td style="text-align: left;">4100332</td>
|
||||
<td style="text-align: left;">Toyota, Hiroko</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
37
test/tables/students.native
Normal file
37
test/tables/students.native
Normal file
|
@ -0,0 +1,37 @@
|
|||
[Table ("students",[],[("source","mdn")]) (Caption Nothing
|
||||
[Para [Str "List", Space, Str "of", Space, Str "Students"]])
|
||||
[(AlignLeft,ColWidth 0.5)
|
||||
,(AlignLeft,ColWidth 0.5)]
|
||||
(TableHead ("",[],[])
|
||||
[Row ("",[],[])
|
||||
[Cell ("",[],[]) AlignCenter (RowSpan 1) (ColSpan 1) [Plain [Str "Student", Space, Str "ID"]]
|
||||
,Cell ("",[],[]) AlignCenter (RowSpan 1) (ColSpan 1) [Plain [Str "Name"]]]])
|
||||
[TableBody ("",["souvereign-states"],[]) (RowHeadColumns 0)
|
||||
[Row ("",[],[])
|
||||
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 2) [Plain [Str "Computer", Space, Str "Science"]]]]
|
||||
[Row ("",[],[])
|
||||
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "3741255"]]
|
||||
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "Jones,", Space, Str "Martha"]]]
|
||||
,Row ("",[],[])
|
||||
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "4077830"]]
|
||||
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "Pierce,", Space, Str "Benjamin"]]]
|
||||
,Row ("",[],[])
|
||||
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "5151701"]]
|
||||
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "Kirk,", Space, Str "James"]]]]
|
||||
,TableBody ("",[],[]) (RowHeadColumns 0)
|
||||
[Row ("",[],[])
|
||||
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 2) [Plain [Str "Russian", Space, Str "Literature"]]]]
|
||||
[Row ("",[],[])
|
||||
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "3971244"]]
|
||||
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "Nim,", Space, Str "Victor"]]]]
|
||||
,TableBody ("",[],[]) (RowHeadColumns 0)
|
||||
[Row ("",[],[])
|
||||
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 2) [Plain [Str "Astrophysics"]]]]
|
||||
[Row ("",[],[])
|
||||
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "4100332"]]
|
||||
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "Petrov,", Space, Str "Alexandra"]]]
|
||||
,Row ("",[],[])
|
||||
[Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "4100332"]]
|
||||
,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "Toyota,", Space, Str "Hiroko"]]]]]
|
||||
(TableFoot ("",[],[]) [])
|
||||
]
|
Loading…
Reference in a new issue