Skip to content
Python markdown extension for insert a space between Chinese / Japanese / Korean and English words, to display beautifully.
Branch: master
Clone or download
Pull request Compare This branch is 7 commits ahead of EloiseSeverin:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
markdown_cjk_spacing
tests
.EditorConfig
.gitattributes
.gitignore
.travis.yml
LICENSE
README-ja.md
README.md
setup.py
tasks.py

README.md

markdown_cjk_spacing

Python markdown extension for insert a space between Chinese / Japanese / Korean and English words, to display beautifully.

中文Chinese西文English is converted to 中文 Chinese 西文 English.

build

Installation

Install with pip.

$ pip install markdown-cjk-spacing

Usage

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',
}

Segment split conversion

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")
You can’t perform that action at this time.