diff --git a/hledger-lib/Hledger/Write/Html/Blaze.hs b/hledger-lib/Hledger/Write/Html/Blaze.hs index 79c5e1b6f..6d356d23e 100644 --- a/hledger-lib/Hledger/Write/Html/Blaze.hs +++ b/hledger-lib/Hledger/Write/Html/Blaze.hs @@ -5,7 +5,7 @@ Export spreadsheet table data as HTML table. This is derived from -} module Hledger.Write.Html.Blaze ( - printHtml, + styledTableHtml, formatRow, formatCell, ) where @@ -22,8 +22,8 @@ import Text.Blaze.Html4.Transitional (Html, toHtml, (!)) import Data.Foldable (traverse_) -printHtml :: (Lines border) => [[Cell border Html]] -> Html -printHtml table = do +styledTableHtml :: (Lines border) => [[Cell border Html]] -> Html +styledTableHtml table = do Html.style $ toHtml $ Attr.tableStylesheet Html.table $ traverse_ formatRow table diff --git a/hledger-lib/Hledger/Write/Html/Lucid.hs b/hledger-lib/Hledger/Write/Html/Lucid.hs index d7eed9a8d..15f36c60d 100644 --- a/hledger-lib/Hledger/Write/Html/Lucid.hs +++ b/hledger-lib/Hledger/Write/Html/Lucid.hs @@ -5,7 +5,7 @@ Export spreadsheet table data as HTML table. This is derived from -} module Hledger.Write.Html.Lucid ( - printHtml, + styledTableHtml, formatRow, formatCell, ) where @@ -23,8 +23,8 @@ import Data.Foldable (traverse_) type Html = Html.Html () -printHtml :: (Lines border) => [[Cell border Html]] -> Html -printHtml table = do +styledTableHtml :: (Lines border) => [[Cell border Html]] -> Html +styledTableHtml table = do Html.link_ [Html.rel_ "stylesheet", Html.href_ "hledger.css"] Html.style_ Attr.tableStylesheet Html.table_ $ traverse_ formatRow table diff --git a/hledger/Hledger/Cli/Commands/Balance.hs b/hledger/Hledger/Cli/Commands/Balance.hs index f5b718c97..f8bc4cad7 100644 --- a/hledger/Hledger/Cli/Commands/Balance.hs +++ b/hledger/Hledger/Cli/Commands/Balance.hs @@ -305,7 +305,7 @@ import Hledger.Cli.Utils import Hledger.Cli.Anchor (setAccountAnchor, dateSpanCell, headerDateSpanCell) import Hledger.Write.Csv (CSV, printCSV, printTSV) import Hledger.Write.Ods (printFods) -import Hledger.Write.Html.Lucid (printHtml) +import Hledger.Write.Html.Lucid (styledTableHtml) import Hledger.Write.Spreadsheet (rawTableContent, headerCell, addHeaderBorders, addRowSpanHeader, cellFromMixedAmount, cellsFromMixedAmount) @@ -392,7 +392,7 @@ balance opts@CliOpts{reportspec_=rspec} j = case balancecalc_ ropts of "csv" -> printCSV . budgetReportAsCsv ropts "tsv" -> printTSV . budgetReportAsCsv ropts "html" -> (<>"\n") . L.renderText . - printHtml . map (map (fmap L.toHtml)) . budgetReportAsSpreadsheet ropts + styledTableHtml . map (map (fmap L.toHtml)) . budgetReportAsSpreadsheet ropts "fods" -> printFods IO.localeEncoding . Map.singleton "Budget Report" . (,) (1,0) . budgetReportAsSpreadsheet ropts _ -> error' $ unsupportedOutputFormatError fmt @@ -418,7 +418,7 @@ balance opts@CliOpts{reportspec_=rspec} j = case balancecalc_ ropts of "csv" -> printCSV . balanceReportAsCsv ropts "tsv" -> printTSV . balanceReportAsCsv ropts "html" -> (<>"\n") . L.renderText . - printHtml . map (map (fmap L.toHtml)) . balanceReportAsSpreadsheet ropts + styledTableHtml . map (map (fmap L.toHtml)) . balanceReportAsSpreadsheet ropts "json" -> (<>"\n") . toJsonText "fods" -> printFods IO.localeEncoding . Map.singleton "Balance Report" . (,) (1,0) . balanceReportAsSpreadsheet ropts _ -> error' $ unsupportedOutputFormatError fmt -- PARTIAL: @@ -711,7 +711,7 @@ tidyColumnLabels = -- | Render a multi-column balance report as HTML. multiBalanceReportAsHtml :: ReportOpts -> MultiBalanceReport -> Html () multiBalanceReportAsHtml ropts mbr = - printHtml . map (map (fmap L.toHtml)) $ + styledTableHtml . map (map (fmap L.toHtml)) $ snd $ multiBalanceReportAsSpreadsheet ropts mbr -- | Render the ODS table rows for a MultiBalanceReport. diff --git a/hledger/Hledger/Cli/Commands/Print.hs b/hledger/Hledger/Cli/Commands/Print.hs index e8a83d872..36966398b 100644 --- a/hledger/Hledger/Cli/Commands/Print.hs +++ b/hledger/Hledger/Cli/Commands/Print.hs @@ -37,7 +37,7 @@ import Hledger import Hledger.Write.Beancount (accountNameToBeancount, showTransactionBeancount, showBeancountMetadata) import Hledger.Write.Csv (CSV, printCSV, printTSV) import Hledger.Write.Ods (printFods) -import Hledger.Write.Html.Lucid (printHtml) +import Hledger.Write.Html.Lucid (styledTableHtml) import qualified Hledger.Write.Spreadsheet as Spr import Hledger.Cli.CliOptions import Hledger.Cli.Utils @@ -142,7 +142,7 @@ printEntries opts@CliOpts{rawopts_=rawopts, reportspec_=rspec} j = | fmt=="json" = toJsonText . styleAmounts styles | fmt=="sql" = entriesReportAsSql . styleAmounts styles | fmt=="html" = - (<>"\n") . Lucid.renderText . printHtml . + (<>"\n") . Lucid.renderText . styledTableHtml . map (map (fmap Lucid.toHtml)) . entriesReportAsSpreadsheet oneLineNoCostFmt baseUrl query . styleAmounts styles diff --git a/hledger/Hledger/Cli/Commands/Register.hs b/hledger/Hledger/Cli/Commands/Register.hs index c55805570..8e5862ff9 100644 --- a/hledger/Hledger/Cli/Commands/Register.hs +++ b/hledger/Hledger/Cli/Commands/Register.hs @@ -31,7 +31,7 @@ import System.Console.CmdArgs.Explicit (flagNone, flagReq) import Hledger hiding (per) import Hledger.Write.Csv (CSV, printCSV, printTSV) import Hledger.Write.Ods (printFods) -import Hledger.Write.Html.Lucid (printHtml) +import Hledger.Write.Html.Lucid (styledTableHtml) import qualified Hledger.Write.Spreadsheet as Spr import Hledger.Cli.CliOptions import Hledger.Cli.Utils @@ -103,7 +103,7 @@ register opts@CliOpts{rawopts_=rawopts, reportspec_=rspec} j | fmt=="csv" = printCSV . postingsReportAsCsv | fmt=="tsv" = printTSV . postingsReportAsCsv | fmt=="html" = - (<>"\n") . Lucid.renderText . printHtml . + (<>"\n") . Lucid.renderText . styledTableHtml . map (map (fmap Lucid.toHtml)) . postingsReportAsSpreadsheet oneLineNoCostFmt baseUrl query | fmt=="fods" = diff --git a/hledger/Hledger/Cli/CompoundBalanceCommand.hs b/hledger/Hledger/Cli/CompoundBalanceCommand.hs index a61a2ac06..86aeacf21 100644 --- a/hledger/Hledger/Cli/CompoundBalanceCommand.hs +++ b/hledger/Hledger/Cli/CompoundBalanceCommand.hs @@ -28,7 +28,7 @@ import System.Console.CmdArgs.Explicit as C (Mode, flagNone, flagReq) import qualified System.IO as IO import Hledger.Write.Ods (printFods) import Hledger.Write.Csv (CSV, printCSV, printTSV) -import Hledger.Write.Html.Lucid (printHtml) +import Hledger.Write.Html.Lucid (styledTableHtml) import Hledger.Write.Html.Attribute (stylesheet, tableStyle, alignleft) import qualified Hledger.Write.Spreadsheet as Spr import Lucid as L hiding (value_) @@ -338,7 +338,7 @@ compoundBalanceReportAsHtml ropts cbr = ] table_ $ do tr_ $ th_ [colspanattr, style_ alignleft] $ h2_ $ toHtml title - printHtml $ NonEmpty.toList $ fmap (map (fmap L.toHtml)) cells + styledTableHtml $ NonEmpty.toList $ fmap (map (fmap L.toHtml)) cells -- | Render a compound balance report as Spreadsheet. compoundBalanceReportAsSpreadsheet ::