denden-extension

Python-Markdown extension for DenDenMarkdown


Keywords
Python-Markdown, DenDenMarkdown, DTP, epub, typesetting, Japanese, ruby, γ§γ‚“γ§γ‚“γƒžγƒΌγ‚―γƒ€γ‚¦γƒ³, ι›»ε­ε‡Ίη‰ˆ, 電子書籍, η΅„η‰ˆ, ζ—₯本θͺž, ルビ
License
MIT
Install
pip install denden-extension==2.0.0

Documentation

denden_extension

Denden_extension is a Python-Markdown extension enables Den-Den Markdown syntax in Python-Markdown.

Requirement

Python-Markdown 2.6 or later.

Install

pip install denden_extension

Usage

Designate denden_extension as extension with other extensions when you use the Python-Markdown.

>>> import markdown
>>> from denden_extension import DenDenExtension
>>> markdown_text = '{ι›»ε­ε‡Ίη‰ˆ|でんししゅっぱん}を手軽に'
>>> html_text = markdown.markdown(markdown_text, extensions=['markdown.extensions.extra', 'markdown.extensions.nl2br', 'markdown.extensions.sane_lists', DenDenExtension()])
>>> html_text
'<p><ruby>ι›»ε­ε‡Ίη‰ˆ<rt>でんししゅっぱん</rt></ruby>を手軽に</p>'

or

>>> import markdown
>>> from denden_extension import DenDenExtension
>>> markdown.markdownFromFile(
...             input='markdown_text.md',
...             output='html_text.html',
...             encoding='utf-8',
...             extensions=['markdown.extensions.extra', 'markdown.extensions.nl2br', 'markdown.extensions.sane_lists', DenDenExtension()],
...             )

or

python -m markdown -x markdown.extensions.extra -x markdown.extensions.nl2br -x markdown.extensions.sane_lists -x denden_extension markdown_text.md > html_text.html

For more details of usage of Python-Markdown, see Python-Markdown documentation.

Options

You can disable some features of denden_extension.

Disable Chunk file syntax:

>>> html_text = markdown.markdown(markdown_text, extensions=['markdown.extensions.extra', 'markdown.extensions.nl2br', 'markdown.extensions.sane_lists', DenDenExtension(docbreak=False)])

Disable Footnotes with epub:type attribute:

>>> html_text = markdown.markdown(markdown_text, extensions=['markdown.extensions.extra', 'markdown.extensions.nl2br', 'markdown.extensions.sane_lists', DenDenExtension(footnote=False)])

If you run the Python-Markdown from command line with an extension with options, you need to prepare the configuration file. For more details, see Python-Markdown documentation.

Description

Den-Den Markdown is an extended Markdown syntax fitted for Japanese and EPUB publishing.
Denden_extension enables the following Den-Den Markdown syntax in Python-Markdown.

*1 Denden_extension depends on the Python-Markdown's footnotes extension for implementing this feature. So you also need the markdown.extensions.footnotes or markdown.extensions.extra which includes the footnotes extension.
*2 Three or more equal signs ('=') on a line by themselves is replaced by a horizontal rule tag with docbreak class attribute (<hr class="docbreak" />).

Den-Den Markdown inherits its syntax from PHP Markdown Extra. In Python-Markdown, PHP Markdown Extra syntax is enabled by markdown.extensions.extra and markdown.extensions.sane_lists, which are included in the Python-Markdown Library.
Also, Den-Den Markdown adopts GFM style line break. This can be enabled by markdown.extensions.nl2br, which is included with the Python-Markdown too.

If you only want to use Den-Den Markdown's original syntax, you just need to designate only markdown.extensions.footnotes and denden_extension.
If you don't use footnotes, only denden_extension is necessary.

The following syntax of Den-Den Markdown is not implemented in denden_extension.

  • Twitter account autolink syntax

For more details of Den-Den Markdown syntax, see http://conv.denshochan.com/markdown (Japanese).

Change log

  • 1.0 (2016-04-29) -- formal release
  • 0.1 (2015-08-23) -- first experimental release

Contact

Contact form