Skip to content

Markup Markdown

Markdown processing utilities.

Markdown Module

Markdown processing utilities.

This submodule provides utilities for converting and escaping Markdown content.

Examples

from rite.markup.markdown import ( ... markdown_to_html, ... markdown_escape ... ) markdown_to_html("bold") 'bold'

Modules

markdown_escape

Markdown Escape

Escape Markdown special characters.

Examples

from rite.markup.markdown import markdown_escape markdown_escape("not italic") '\not italic\'

Functions

markdown_escape(text: str) -> str

Escape Markdown special characters.

Parameters:

Name Type Description Default
text str

Text to escape.

required

Returns:

Type Description
str

Escaped text.

Examples:

>>> markdown_escape("# Not a heading")
'\\# Not a heading'
>>> markdown_escape("[not](link)")
'\\[not\\]\\(link\\)'
Notes

Escapes: *, _, #, [, ], (, ), `, ~ Prevents Markdown interpretation.

markdown_to_html

Markdown to HTML

Convert Markdown to HTML (basic).

Examples

from rite.markup.markdown import markdown_to_html markdown_to_html("bold text") 'bold text'

Functions

markdown_to_html(markdown: str) -> str

Convert basic Markdown to HTML.

Parameters:

Name Type Description Default
markdown str

Markdown text.

required

Returns:

Type Description
str

HTML string.

Examples:

>>> markdown_to_html("# Heading")
'<h1>Heading</h1>'
>>> markdown_to_html("**bold** and *italic*")
'<strong>bold</strong> and <em>italic</em>'
Notes

Basic conversion only. Supports: headings, bold, italic, code. For full Markdown, use external library.

options: show_root_heading: true show_source: false heading_level: 2