html - Pandoc 元数据未出现在默认 HTML 模板中
问题描述
我正在使用 pandoc 将 org 和 markdown 文件转换为 HTML。我想在外部 YAML 文件中设置元数据,例如title
、subtitle
和标签,并使用模板显示它们。author
但是,除了正常的身体转换之外,我什么都看不到。
我正在使用默认的 HTML 模板。我已经预先运行了连接 YAML 配置的转换:
pandoc -t html -o output.html metadata.yaml input.md
我也尝试包括yaml_metadata_block
扩展:
pandoc -t html+yaml_metadata_block -o output.html metadata.yaml input.md
另外,我尝试在命令本身中设置变量:
pandoc -t html -o output.html -V title="my title" input.md
我的 YAML 文件如下所示:
---
title: "my title"
subtitle: "my subtitle"
author: "the author"
...
用 来检查默认的 html 模板pandoc -D html
,看起来当title
etc. 被定义时,它会放在一个标题块中:
$if(title)$
<header>
<h1 class="title">$title$</h1>
$if(subtitle)$
<p class="subtitle">$subtitle$</p>
$endif$
$for(author)$
<p class="author">$author$</p>
$endfor$
$if(date)$
<p class="date">$date$</p>
$endif$
</header>
但在任何情况下,html 文件都只包含从input.md
. 我认为这是$body$
默认模板中定义的行。
如何让这些字段出现在我的 html 文档中?
解决方案
我的天哪,我所缺少的只是-s
属性!
从手册页:
-s, --standalone
Produce output with an appropriate header and footer (e.g. a standalone HTML, LaTeX, TEI, or RTF file, not a fragment). This option is set automat‐
ically for pdf, epub, epub3, fb2, docx, and odt output.
因此,以下命令按预期工作
pandoc -s -t html -o output.html metadata.yaml input.md
推荐阅读
- grafana - 在 Grafana 中,如何使用我创建的变量并将其作为值提供给图形的查询搜索?
- microservices - 如何使用 JHipster 从网关生成单独的前端?
- python - 使用 ipywidgets 为 pandas df 中的每一行分配一个复选框
- html - Angular2将来自服务器的html包含到一个div中
- javascript - GraphQL 的突变上的“意外的令牌 < 在 JSON 中的位置 0”
- flutter - 如何使用盒子阴影显示容器的高度,如抽屉(更多深度 z 轴)?
- visual-studio - 复制 +,, 没有按预期工作:文件被触摸但也被复制
- javascript - asp.net 代码不调用 javascript 函数
- java - 如何在 Java 中实现构建特定的注解保留
- php - 我无法在 Godaddy 服务器上使用 CURL