0
我正在閱讀模板文件,將降價文件轉換爲html文件並嘗試讓IO與純系統搭配使用。如何在使用IO字符串模板時使用Pandoc的writeHtmlString
template :: IO String
template = readFile "/File/Path/template.html"
siteOptions :: WriterOptions
siteOptions = def { writerStandalone = True, writerTemplate = template }
convertMdtoHtml :: FilePath -> IO()
convertMdtoHtml file = do
contents <- readFile file
let pandoc = readMarkdown def contents
let html = writeHtmlString siteOptions pandoc
writeFile (file ++ ".html") html
下面是writeHtmlString,我試圖用http://hackage.haskell.org/packages/archive/pandoc/1.11.1/doc/html/Text-Pandoc-Writers-HTML.html
試圖運行,這是
Couldn't match expected type `String' with actual type `IO String'
,當我得到的錯誤的文檔有任何方式做到這一點haskell還是我需要將模板文件作爲字符串已經在代碼中。
謝謝
感謝米哈伊爾回答這麼快。我認爲細節很多,忘記了整體情況。感謝TemplateHaskell上的其他細節,我認爲這樣的東西對我所要做的事情來說太過分了。 – Lazydancer