fix: html: Nested tables resulting in broken HTML on export
A HTML export results in a table which has a stylesheet and another table nested inside. This is not valid HTML and gets auto corrected by closing the first table and opening another table. The result is the heading of the table can expand further than the remaining table. This results in a few notable changes: - The date is in a far bigger cell and it's very noticeable it's centered compared to the amounts (we may want to right align the date, though I don't have any particular thoughts about this) - We no longer have two consecutive lines with black background and the start - The table is as big as the heading (+ the default left margin)
This commit is contained in:
parent
6111706eba
commit
e2f2a22346
@ -16,6 +16,7 @@ module Hledger.Cli.CompoundBalanceCommand (
|
||||
|
||||
import Control.Monad (guard)
|
||||
import Data.Bifunctor (second)
|
||||
import Data.Foldable (traverse_)
|
||||
import Data.Function ((&))
|
||||
import Data.List.NonEmpty (NonEmpty((:|)))
|
||||
import Data.Maybe (fromMaybe, mapMaybe, maybeToList)
|
||||
@ -36,7 +37,7 @@ import Hledger.Cli.Commands.Balance
|
||||
import Hledger.Cli.CliOptions
|
||||
import Hledger.Cli.Utils (unsupportedOutputFormatError, writeOutputLazyText)
|
||||
import Hledger.Write.Csv (CSV, printCSV, printTSV)
|
||||
import Hledger.Write.Html (htmlAsLazyText, styledTableHtml, Html)
|
||||
import Hledger.Write.Html (formatRow, htmlAsLazyText, Html)
|
||||
import Hledger.Write.Html.Attribute (stylesheet, tableStyle, alignleft)
|
||||
import Hledger.Write.Ods (printFods)
|
||||
import Hledger.Write.Spreadsheet qualified as Spr
|
||||
@ -339,7 +340,8 @@ compoundBalanceReportAsHtml ropts cbr =
|
||||
]
|
||||
table_ $ do
|
||||
tr_ $ th_ [colspanattr, style_ alignleft] $ h2_ $ toHtml title
|
||||
styledTableHtml $ NonEmpty.toList $ fmap (map (fmap L.toHtml)) cells
|
||||
-- Do not use `styledTableHtml` here since that leads to nested `<table>`s.
|
||||
traverse_ formatRow $ fmap (map (fmap L.toHtml)) cells
|
||||
|
||||
-- | Render a compound balance report as Spreadsheet.
|
||||
compoundBalanceReportAsSpreadsheet ::
|
||||
|
||||
Loading…
Reference in New Issue
Block a user