Python markdown extension for insert a space between Chinese / Japanese / Korean and English words, to display beautifully.
中文Chinese西文English
is converted to 中文 Chinese 西文 English
.
Install with pip.
$ pip install markdown-cjk-spacing
It is used as an extension of Python-Markdown.
import markdown
md = markdown.Markdown(extensions=["markdown_cjk_spacing.cjk_spacing"])
md.convert("markdown text")
Or use from Pelican as Markdown extension.
# pelicanconf.py
MARKDOWN = {
'extension_configs': {
'markdown.extensions.codehilite': {'css_class': 'highlight'},
'markdown.extensions.extra': {},
'markdown.extensions.meta': {},
'markdown_cjk_spacing.cjk_spacing': {},
},
'output_format': 'html5',
}
In Chinese / Japanese sentences, if you do a line feed, it will be a one-byte space, but you can delete this space.
import markdown
md = markdown.Markdown(extensions=["markdown_cjk_spacing.cjk_spacing"],
extension_configs={'markdown_cjk_spacing.cjk_spacing':
{'segment_break': True}})
md.convert("markdown text")