【发布时间】:2013-06-12 00:06:18
【问题描述】:
我在将 markdown 文件转换为 html 文件并尝试让 IO 与纯系统配合使用时正在读取模板文件。
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中做到这一点,或者我需要将模板文件作为字符串已经存在于代码中。
谢谢
【问题讨论】: