Pandoc HTML Table 的内容输出

Pandoc HTML Table of Contents Output

我正在使用 pandoc(不是命令行上的 executable,而是 haskell 库),我正在生成 HTML 输出。我无法使 table 的内容出现在输出中。大致上,我有这个:

...
writeHtml (def {writerTOCDepth = 4, writerTableOfContents = True} m)
where m =
  [ Header 1 ("myIdentifier",[],[]) [Str "Vulnerabilities"]                                           
  , Div nullAttr otherStuff                                                                                
  ]

我觉得仅此一项就足以获得具有简单 table 内容的 HTML 输出(漏洞部分只有 link)。如果有人看到我遗漏的内容,我将不胜感激。

编辑

我认为这个问题与我需要设置 writerStandalone = True 有关,但是当我这样做时,生成的文档是完全空白的。

想通了。您必须打开独立模式并设置模板:

loadReportPandocOpts :: IO WriterOptions                                                              
loadReportPandocOpts = do
  t <- readFile "resources/report-template.html"                                                      
  return def
    { writerTOCDepth = 4
    , writerTableOfContents = True                                                                    
    , writerHtml5 = True                                                                              
    , writerStandalone = True                                                                         
    , writerTemplate = t                                                                              
    }

模板应如下所示:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <meta name="generator" content="pandoc" />
  </head>
  <body>
    <div>$toc$</div>
    <div>$body$</div>
  </body>
</html>