我在kramdown中写笔记,然后使用kramdown
转换器获取一个html文件在本地读取(不在服务器上)。
$ kramdown notes.txt > notes.html
我的工作流程是不断更新notes.txt
,然后快速呈现notes.html
以查看它。
我想对笔记进行样式设置,因此我创建了一个格式化HTML主体的CSS文件notes_style.css
:
body {
...
}
我在<head>
添加了notes.txt
标记,并添加了指向样式表的链接。然后我在<body>
:
notes.txt
个标记
<head>
<link rel="stylesheet" type="txt/css" href="themes/notes_style.css" />
</head>
<body>
...
</body>
然后我意识到,由于kramdown
忽略了HTML块,<body>
中的任何内容都不会转换为HTML。如何在将kramdown转换为HTML的同时设置<body>
的内容样式?每次使用<body>
时,我都不想手动添加kramdown
代码。
我怀疑我的工作流程出了点问题,但不确定正确的做法是什么。
答案 0 :(得分:2)
Kramdown有parse_block_html
option,导致它解析HTML元素的内容。您可以像这样使用它:
$ kramdown --parse-block-html notes.txt > notes.html
或者,Kramdown也会寻找special markdown
attribute on HTML elements。如果设置为'1'
,则Kramdown会将该元素的内容解析为markdown。所以你可以这样做(你需要1
左右的引号,Kramdown的HTML解析器非常严格):
<head>
<link rel="stylesheet" type="txt/css" href="themes/notes_style.css" />
</head>
<body markdown='1'>
Content here will be parsed _as Markdown_.
</body>
在这两种情况下,您的body
内容都需要保持正常对齐,您不能缩进它,因为您可能会自然地编写嵌套在元素中的HTML。