我正在使用pandoc(不是命令行上的可执行文件,而是haskell库),我正在生成HTML输出.我无法使目录显示在输出中.粗略地说,我有这个:
...
writeHtml (def {writerTOCDepth = 4, writerTableOfContents = True} m)
where m =
  [ Header 1 ("myIdentifier",[],[]) [Str "Vulnerabilities"]                                           
  , Div nullAttr otherStuff                                                                                
  ]
我觉得仅凭这一点就足以让HTML输出带有一个简单的目录(只有一个链接到Vulnerabilities部分的链表).如果有人看到我错过了什么,我将不胜感激.
编辑
我认为这个问题与我需要设置有关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>
| 归档时间: | 
 | 
| 查看次数: | 1295 次 | 
| 最近记录: |