Only use concat

This commit is contained in:
Niels G. W. Serup 2024-10-05 20:28:25 +02:00
parent d96af50943
commit 9240d66c15
No known key found for this signature in database
GPG Key ID: 38EEEBCE67324F19
2 changed files with 15 additions and 17 deletions

View File

@ -107,6 +107,9 @@ instance TokenableTo a (Token a) where
instance TokenableTo [a] [Token a] where
toToken = pure . ListToken
instance TokenableTo [a] [DepGenM' a] where
toToken = fmap ListToken . sequence
instance TokenableTo a (DepGenM' a) where
toToken = id

View File

@ -17,15 +17,12 @@ thumbnailImageFilename filename = do
makeImageHTML :: Token (FilePath, FilePath) -> DepGenM' Text
makeImageHTML t = do
(thumbnail, actual) <- untupleDepGenM t
appendTexts
(inject "<p class=\"image\"><a href=\"")
(appendTexts
(toText actual)
(appendTexts
(inject "\"><img src=\"")
(appendTexts
(toText thumbnail)
(inject "\"></a></p>"))))
concatTexts [ inject "<p class=\"image\"><a href=\""
, toText actual
, inject "\"><img src=\""
, toText thumbnail
, inject "\"></a></p>"
]
hasExtension :: (TokenableTo [String] a, TokenableTo FilePath b) => a -> b -> DepGenM' Bool
hasExtension exts filename = do
@ -53,14 +50,12 @@ handleRecipeDir inputDir outputDir template indexName name = do
mdTemplate <- makeTemplate md ingredienserHeadline
htmlBodyImages <- mapDepGenM makeImageHTML $ zipDepGenM thumbnailImageFilenames imageFilenames
imagesHtml <- concatTexts htmlBodyImages
md' <- applyTemplate mdTemplate (
appendTexts
(inject "<p class=\"imagetext\">Opskrift fortsætter efter billedet.</p>\n")
(appendTexts
imagesHtml
(appendTexts
(inject "\n\n")
ingredienserHeadline)))
md' <- applyTemplate mdTemplate
$ concatTexts [ inject "<p class=\"imagetext\">Opskrift fortsætter efter billedet.</p>\n"
, pure imagesHtml
, inject "\n\n"
, pure ingredienserHeadline
]
htmlBody <- runPandoc md'
html <- applyTemplate template htmlBody
saveFile html $ joinPaths recipeDirOut indexName