dev: rename printHtml -> styledTableHtml

This commit is contained in:
Simon Michael 2025-01-23 06:42:29 -10:00
parent 9d4db48510
commit 14dd2c6200
6 changed files with 16 additions and 16 deletions

View File

@ -5,7 +5,7 @@ Export spreadsheet table data as HTML table.
This is derived from <https://hackage.haskell.org/package/classify-frog-0.2.4.3/src/src/Spreadsheet/Format.hs> This is derived from <https://hackage.haskell.org/package/classify-frog-0.2.4.3/src/src/Spreadsheet/Format.hs>
-} -}
module Hledger.Write.Html.Blaze ( module Hledger.Write.Html.Blaze (
printHtml, styledTableHtml,
formatRow, formatRow,
formatCell, formatCell,
) where ) where
@ -22,8 +22,8 @@ import Text.Blaze.Html4.Transitional (Html, toHtml, (!))
import Data.Foldable (traverse_) import Data.Foldable (traverse_)
printHtml :: (Lines border) => [[Cell border Html]] -> Html styledTableHtml :: (Lines border) => [[Cell border Html]] -> Html
printHtml table = do styledTableHtml table = do
Html.style $ toHtml $ Attr.tableStylesheet Html.style $ toHtml $ Attr.tableStylesheet
Html.table $ traverse_ formatRow table Html.table $ traverse_ formatRow table

View File

@ -5,7 +5,7 @@ Export spreadsheet table data as HTML table.
This is derived from <https://hackage.haskell.org/package/classify-frog-0.2.4.3/src/src/Spreadsheet/Format.hs> This is derived from <https://hackage.haskell.org/package/classify-frog-0.2.4.3/src/src/Spreadsheet/Format.hs>
-} -}
module Hledger.Write.Html.Lucid ( module Hledger.Write.Html.Lucid (
printHtml, styledTableHtml,
formatRow, formatRow,
formatCell, formatCell,
) where ) where
@ -23,8 +23,8 @@ import Data.Foldable (traverse_)
type Html = Html.Html () type Html = Html.Html ()
printHtml :: (Lines border) => [[Cell border Html]] -> Html styledTableHtml :: (Lines border) => [[Cell border Html]] -> Html
printHtml table = do styledTableHtml table = do
Html.link_ [Html.rel_ "stylesheet", Html.href_ "hledger.css"] Html.link_ [Html.rel_ "stylesheet", Html.href_ "hledger.css"]
Html.style_ Attr.tableStylesheet Html.style_ Attr.tableStylesheet
Html.table_ $ traverse_ formatRow table Html.table_ $ traverse_ formatRow table

View File

@ -305,7 +305,7 @@ import Hledger.Cli.Utils
import Hledger.Cli.Anchor (setAccountAnchor, dateSpanCell, headerDateSpanCell) import Hledger.Cli.Anchor (setAccountAnchor, dateSpanCell, headerDateSpanCell)
import Hledger.Write.Csv (CSV, printCSV, printTSV) import Hledger.Write.Csv (CSV, printCSV, printTSV)
import Hledger.Write.Ods (printFods) import Hledger.Write.Ods (printFods)
import Hledger.Write.Html.Lucid (printHtml) import Hledger.Write.Html.Lucid (styledTableHtml)
import Hledger.Write.Spreadsheet (rawTableContent, headerCell, import Hledger.Write.Spreadsheet (rawTableContent, headerCell,
addHeaderBorders, addRowSpanHeader, addHeaderBorders, addRowSpanHeader,
cellFromMixedAmount, cellsFromMixedAmount) cellFromMixedAmount, cellsFromMixedAmount)
@ -392,7 +392,7 @@ balance opts@CliOpts{reportspec_=rspec} j = case balancecalc_ ropts of
"csv" -> printCSV . budgetReportAsCsv ropts "csv" -> printCSV . budgetReportAsCsv ropts
"tsv" -> printTSV . budgetReportAsCsv ropts "tsv" -> printTSV . budgetReportAsCsv ropts
"html" -> (<>"\n") . L.renderText . "html" -> (<>"\n") . L.renderText .
printHtml . map (map (fmap L.toHtml)) . budgetReportAsSpreadsheet ropts styledTableHtml . map (map (fmap L.toHtml)) . budgetReportAsSpreadsheet ropts
"fods" -> printFods IO.localeEncoding . "fods" -> printFods IO.localeEncoding .
Map.singleton "Budget Report" . (,) (1,0) . budgetReportAsSpreadsheet ropts Map.singleton "Budget Report" . (,) (1,0) . budgetReportAsSpreadsheet ropts
_ -> error' $ unsupportedOutputFormatError fmt _ -> error' $ unsupportedOutputFormatError fmt
@ -418,7 +418,7 @@ balance opts@CliOpts{reportspec_=rspec} j = case balancecalc_ ropts of
"csv" -> printCSV . balanceReportAsCsv ropts "csv" -> printCSV . balanceReportAsCsv ropts
"tsv" -> printTSV . balanceReportAsCsv ropts "tsv" -> printTSV . balanceReportAsCsv ropts
"html" -> (<>"\n") . L.renderText . "html" -> (<>"\n") . L.renderText .
printHtml . map (map (fmap L.toHtml)) . balanceReportAsSpreadsheet ropts styledTableHtml . map (map (fmap L.toHtml)) . balanceReportAsSpreadsheet ropts
"json" -> (<>"\n") . toJsonText "json" -> (<>"\n") . toJsonText
"fods" -> printFods IO.localeEncoding . Map.singleton "Balance Report" . (,) (1,0) . balanceReportAsSpreadsheet ropts "fods" -> printFods IO.localeEncoding . Map.singleton "Balance Report" . (,) (1,0) . balanceReportAsSpreadsheet ropts
_ -> error' $ unsupportedOutputFormatError fmt -- PARTIAL: _ -> error' $ unsupportedOutputFormatError fmt -- PARTIAL:
@ -711,7 +711,7 @@ tidyColumnLabels =
-- | Render a multi-column balance report as HTML. -- | Render a multi-column balance report as HTML.
multiBalanceReportAsHtml :: ReportOpts -> MultiBalanceReport -> Html () multiBalanceReportAsHtml :: ReportOpts -> MultiBalanceReport -> Html ()
multiBalanceReportAsHtml ropts mbr = multiBalanceReportAsHtml ropts mbr =
printHtml . map (map (fmap L.toHtml)) $ styledTableHtml . map (map (fmap L.toHtml)) $
snd $ multiBalanceReportAsSpreadsheet ropts mbr snd $ multiBalanceReportAsSpreadsheet ropts mbr
-- | Render the ODS table rows for a MultiBalanceReport. -- | Render the ODS table rows for a MultiBalanceReport.

View File

@ -37,7 +37,7 @@ import Hledger
import Hledger.Write.Beancount (accountNameToBeancount, showTransactionBeancount, showBeancountMetadata) import Hledger.Write.Beancount (accountNameToBeancount, showTransactionBeancount, showBeancountMetadata)
import Hledger.Write.Csv (CSV, printCSV, printTSV) import Hledger.Write.Csv (CSV, printCSV, printTSV)
import Hledger.Write.Ods (printFods) 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 qualified Hledger.Write.Spreadsheet as Spr
import Hledger.Cli.CliOptions import Hledger.Cli.CliOptions
import Hledger.Cli.Utils import Hledger.Cli.Utils
@ -142,7 +142,7 @@ printEntries opts@CliOpts{rawopts_=rawopts, reportspec_=rspec} j =
| fmt=="json" = toJsonText . styleAmounts styles | fmt=="json" = toJsonText . styleAmounts styles
| fmt=="sql" = entriesReportAsSql . styleAmounts styles | fmt=="sql" = entriesReportAsSql . styleAmounts styles
| fmt=="html" = | fmt=="html" =
(<>"\n") . Lucid.renderText . printHtml . (<>"\n") . Lucid.renderText . styledTableHtml .
map (map (fmap Lucid.toHtml)) . map (map (fmap Lucid.toHtml)) .
entriesReportAsSpreadsheet oneLineNoCostFmt baseUrl query . entriesReportAsSpreadsheet oneLineNoCostFmt baseUrl query .
styleAmounts styles styleAmounts styles

View File

@ -31,7 +31,7 @@ import System.Console.CmdArgs.Explicit (flagNone, flagReq)
import Hledger hiding (per) import Hledger hiding (per)
import Hledger.Write.Csv (CSV, printCSV, printTSV) import Hledger.Write.Csv (CSV, printCSV, printTSV)
import Hledger.Write.Ods (printFods) 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 qualified Hledger.Write.Spreadsheet as Spr
import Hledger.Cli.CliOptions import Hledger.Cli.CliOptions
import Hledger.Cli.Utils import Hledger.Cli.Utils
@ -103,7 +103,7 @@ register opts@CliOpts{rawopts_=rawopts, reportspec_=rspec} j
| fmt=="csv" = printCSV . postingsReportAsCsv | fmt=="csv" = printCSV . postingsReportAsCsv
| fmt=="tsv" = printTSV . postingsReportAsCsv | fmt=="tsv" = printTSV . postingsReportAsCsv
| fmt=="html" = | fmt=="html" =
(<>"\n") . Lucid.renderText . printHtml . (<>"\n") . Lucid.renderText . styledTableHtml .
map (map (fmap Lucid.toHtml)) . map (map (fmap Lucid.toHtml)) .
postingsReportAsSpreadsheet oneLineNoCostFmt baseUrl query postingsReportAsSpreadsheet oneLineNoCostFmt baseUrl query
| fmt=="fods" = | fmt=="fods" =

View File

@ -28,7 +28,7 @@ import System.Console.CmdArgs.Explicit as C (Mode, flagNone, flagReq)
import qualified System.IO as IO import qualified System.IO as IO
import Hledger.Write.Ods (printFods) import Hledger.Write.Ods (printFods)
import Hledger.Write.Csv (CSV, printCSV, printTSV) 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 Hledger.Write.Html.Attribute (stylesheet, tableStyle, alignleft)
import qualified Hledger.Write.Spreadsheet as Spr import qualified Hledger.Write.Spreadsheet as Spr
import Lucid as L hiding (value_) import Lucid as L hiding (value_)
@ -338,7 +338,7 @@ compoundBalanceReportAsHtml ropts cbr =
] ]
table_ $ do table_ $ do
tr_ $ th_ [colspanattr, style_ alignleft] $ h2_ $ toHtml title 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. -- | Render a compound balance report as Spreadsheet.
compoundBalanceReportAsSpreadsheet :: compoundBalanceReportAsSpreadsheet ::