Pelican的CommonMark/Front Matter阅读器
项目描述
Pelican FrontMark
A Pelican CommonMark/Front Matter reader.
This reader marse Markdown files with YAML frontmatter headers and formatted using the CommonMark specifications.
需求
Pelican FrontMark works with Pelican 3.7+ and Python 3.3+
入门
使用pip安装pelican-frontmark
pip install pelican-frontmark
并在您的pelicanconf.py(或任何您想使用的配置文件)中启用插件
PLUGINS = [
'...',
'frontmark',
'...',
]
文件格式
Frontmark仅识别使用.md扩展名的文件。
以下是一篇文章示例
---
title: My article title
date: 2017-01-04 13:10
modified: 2017-01-04 13:13
tags:
- tag 1
- tag 2
slug: my-article-slug
lang: en
category: A category
authors: Me
summary: Some summary
status: draft
custom:
title: A custom metadata
details: You can add any structured and typed YAML metadata
---
My article content
高级配置
语法高亮显示
默认情况下,FrontMark以标准html5方式输出代码块,即一个具有语言类的pre>code块。这允许使用任何html5语法高亮JavaScript库。
您可以将FRONTMARK_PYGMENTS设置为True强制使用Pygments以输出html4预渲染的语法高亮,或者手动将其设置为Pygments HtmlRenderer参数的字典。
FRONTMARK_PYGMENTS = {
'linenos': 'inline',
}
设置
`FRONTMARK_PARSE_LITERAL`: 默认值为True。如果您不想将多行字符串文字(|)解析为Markdown,请将其设置为False。
`FRONTMARK_PYGMENTS`:默认未定义,输出标准html5代码块。可以设置为True,强制使用默认参数的Pygments或一个包含Pygments参数的字典
注册自定义YAML类型
您可以使用frontmark_yaml_register信号注册自定义YAML类型
from frontmark.signals import frontmark_yaml_register
def upper_constructor(loader, noder):
return loader.construct_scalar(node).upper()
def register_upper(reader):
return '!upper', upper_constructor
def register():
frontmark_yaml_register.connected(register_upper):
测试
要测试插件对所有支持的Python版本的兼容性,请运行tox
tox
要仅使用pytest测试当前Python版本,请
pip install -e .[test] # Install with test dependencies
pytest # Launch pytest test suite
或者让setuptools来完成这项工作
python setup.py test
变更日志
1.2.1 (2019-12-09)
支持CommonMark 0.9.1
1.2.0 (2018-09-08)
升级到CommonMark 0.8+
停止支持低于3.5的Python版本
1.1.0 (2017-01-22)
添加了用于Pygments渲染的FRONTMARK_PYGMENTS可选设置
修复了链接处理(即 {filename}…)
1.0.1 (2017-01-08)
测试并修复插件注册
在模块级别提供版本和描述
1.0.0 (2017-01-08)
初始版本
项目详情
pelican_frontmark-1.2.1-py2.py3-none-any.whl的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 365c3e0ffdf1e467f3585f3b934300c5b55a2dc13148f158fcb8ea003df1c55a |
|
MD5 | 18ac9085fe1772a5c92d5cc8d67b8796 |
|
BLAKE2b-256 | 42d95d51fb9ef82c0040699c167e729323f2cb8a193bd7b18d1a80358589ea49 |