pandoc - 如何在 Pandoc 生成的 HTML 中包含元标记?

标签 pandoc

我正在使用 Pandoc 编写站点的内容。如何在文档中包含元标记(特别是描述和关键字标记),而不更改传递给 Pandoc 的命令行参数?

我的意思是,我可以在文档文本中以某种方式包含元标记吗?我不想传递命令行选项,因为有几个不同的页面,有不同的关键字,我想从 Emacs 中发送到 Pandoc,并且自定义它们中的每一个都是一个问题。

最佳答案

我发现添加 --self-contained-s pandoc 的选项命令允许在顶部的 YAML 中为每个文件定义 header 内容。

例如:

$ cat foo.md
---
title: Foo
header-includes:
    <meta name="keywords" content="Foo,Bar" />
    <meta name="description" content="My description" />
---

# Bar #

Baz
$ pandoc -s -o foo.html foo.md
$ cat foo.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<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" />
  <title>Foo</title>
  <style type="text/css">code{white-space: pre;}</style>
  <meta name="keywords" content="Foo,Bar" /> <meta name="description" content="My description" />
</head>
<body>
<div id="header">
<h1 class="title">Foo</h1>
</div>
<h1 id="bar">Bar</h1>
<p>Baz</p>
</body>
</html>

关于pandoc - 如何在 Pandoc 生成的 HTML 中包含元标记?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25410701/

相关文章:

Pandoc HTML 到 PDF(带样式)

r - 在 r markdown 中包装 pandoc 表列名

markdown - 如何在 Markdown 中创建注释文本框?

html - 在 HTML 中使用 `pandoc-citeproc` 渲染引用书目

html - 如何使用 Pandoc 将带有 mathjax 的 HTML 转换为 Latex?

r - 如何使用 rmarkdown 和 pandoc 在表格中编写(项目符号)列表

linux - pcmanfm-qt 自定义操作中的多个命令?

latex - 在 Pandoc Markdown 中创建多级枚举列表

latex - 使用Pandoc从Markdown转换为PDF时设置双倍行距和行号

markdown - Pandoc Markdown : Multiparagraph list with code blocks