Bootstrap 和 Pandoc 的代码块格式问题
Code block formatting issues with Bootstrap and Pandoc
我在 Pandoc 降价文件中有一个代码块指定为:
```python
for x in range(10):
print('id is', x)
```
当我使用命令时
pandoc example.md -s -o example.html
我在网页中得到以下输出:
但是,当我使用使用 Bootstrap CSS 生成 HTML 的自定义 html 模板时,代码块中的缩进是错误的。命令
pandoc example.md --template=custom.html -s -o example2.html
在网页中产生以下输出:
请注意第二个示例中的缩进太大。只有在 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>
我在 Pandoc 降价文件中有一个代码块指定为:
```python
for x in range(10):
print('id is', x)
```
当我使用命令时
pandoc example.md -s -o example.html
我在网页中得到以下输出:
但是,当我使用使用 Bootstrap CSS 生成 HTML 的自定义 html 模板时,代码块中的缩进是错误的。命令
pandoc example.md --template=custom.html -s -o example2.html
在网页中产生以下输出:
请注意第二个示例中的缩进太大。只有在 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>