【问题标题】:Pandoc HTML Table of Contents OutputPandoc HTML 目录输出
【发布时间】:2015-09-02 20:57:36
【问题描述】:

我正在使用 pandoc(不是命令行上的可执行文件,而是 haskell 库),并且正在生成 HTML 输出。我无法使目录出现在输出中。大致上,我有这个:

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

我觉得仅此一项就足以获得带有简单目录的 HTML 输出(只有一个指向漏洞部分的链接)。如果有人看到我遗漏的内容,我将不胜感激。

编辑

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

【问题讨论】:

    标签: haskell pandoc


    【解决方案1】:

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

    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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-09
      • 1970-01-01
      • 2011-11-16
      • 2013-06-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多