html - Bootstrap 和 Pandoc 的代码块格式问题

标签 html twitter-bootstrap markdown pandoc pre

我在 Pandoc markdown 文件中有一个代码块指定为:

```python
for x in range(10):
  print('id is', x)
```

当我使用命令时

pandoc example.md -s -o example.html

我在网页中得到以下输出:

enter image description here

但是,当我使用使用 Bootstrap CSS 生成 HTML 的自定义 html 模板时,代码块中的缩进是错误的。命令

pandoc example.md --template=custom.html -s -o example2.html

在网页中产生以下输出:

example two

请注意第二个示例中的缩进太大。只有当使用 Bootstrap 来设置代码块的样式时才会发生这种情况。缩进问题不会出现在第一行,只会出现在代码块中的后续行。

我用来生成 HTML 的模板是:

<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Example Pandoc HTML</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

    $if(quotes)$
      <style type="text/css">q { quotes: "“" "”" "‘" "’"; }</style>
    $endif$

    $if(highlighting-css)$
      <style type="text/css">$highlighting-css$</style>
    $endif$

    $if(math)$
      $math$
    $endif$
  </head>

  <body>

    <div class="container">
      $body$
    </div>

  </body>

</html>

在使用自定义 HTML 模板时,如何使用 Bootstrap 和 Pandoc 正确格式化代码块?

最佳答案

在您的模板中取消缩进 $body$,它不会缩进您的代码块。

    <div class="container">
$body$
    </div>

关于html - Bootstrap 和 Pandoc 的代码块格式问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42773587/

相关文章:

javascript - 如何通过 <a> 使用 Jquery 获取 div 中第一个子项的值

r - 彩色打印 R 标记 html

html - 是否可以在 knit 中的 kable 函数中给出分隔列的垂直线?

html - 内联图像,每个图像下方都带有标题?

javascript - 通过单击按钮从 javascript 和 php 调用两个函数

javascript - 使用 ReactJS 自动选择 span 标签

jquery - Bootstrap v3.0.2 选项卡无法正常工作

html - 如何让我的图像和 div 位于同一行和高度上?

html - 如何在不影响导航栏高度的情况下扩展 Bootstrap 导航栏品牌的背景颜色

css - 如何在 R Markdown 中为纯文本代码栅栏获取灰色背景?