Skip to main content

tags: [gradio-custom-component, Markdown] title: gradio_somarkdown short_description: A custom Gradio component that renders Markdown with KaTeX math, SMILES chemical structures, mhchem equations, and syntax-highlighted code blocks. colorFrom: blue colorTo: yellow sdk: gradio pinned: false app_file: space.py

gradio_somarkdown

Static Badge

A custom Gradio component that replaces gr.Markdown with the SoMarkDown renderer — adding KaTeX math, SMILES chemical structures, mhchem chemical equations, syntax-highlighted code blocks, and Table of Contents generation.

Installation

pip install gradio_somarkdown

Usage

import gradio as gr
from gradio_somarkdown import SoMarkDown

example = r"""
## Math
$$ E = mc^2 $$  Inline: $e^{i\pi} + 1 = 0$

## Chemical Structure
$$ \smiles{CC(=O)Oc1ccccc1C(=O)O} $$

## Chemistry (mhchem)
$$ \ce{CO2 + C -> 2 CO} $$

## Code
```python
def fib(n):
    return n if n <= 1 else fib(n-1) + fib(n-2)

"""

with gr.Blocks() as demo: SoMarkDown(value=example, katex={"throwOnError": False})

demo.launch()


## `SoMarkDown`

### Initialization

| name | type | default | description |
|:-----|:-----|:--------|:------------|
| `value` | `str \| Callable \| None` | `None` | SoMarkdown content to render. Accepts a callable for dynamic values. |
| `linkify` | `bool` | `True` | Auto-convert URL-like text to links. |
| `typographer` | `bool` | `True` | Enable smart quotes and language-neutral typographic replacements. |
| `katex` | `dict \| None` | `None` | KaTeX options (e.g. `{"throwOnError": False}`). `trust` and `strict` are always forced to `True`/`False`. |
| `smiles` | `dict \| None` | `None` | SMILES renderer options (e.g. `{"disableColors": False, "width": 150, "height": 150}`). |
| `img_desc_enabled` | `bool` | `True` | Show image descriptions below images. |
| `rtl` | `bool` | `False` | Right-to-left text direction. |
| `height` | `int \| str \| None` | `None` | Fixed height; content scrolls when it overflows. |
| `max_height` | `int \| str \| None` | `None` | Maximum height; shrinks to content when shorter. |
| `min_height` | `int \| str \| None` | `None` | Minimum height; expands to content when taller. |
| `container` | `bool` | `False` | Wrap in a Gradio Block container. |
| `padding` | `bool` | `False` | Apply `--block-padding` CSS variable. |

Backward-compatibility parameters from `gr.Markdown` (`sanitize_html`, `header_links`, `line_breaks`, `buttons`, `latex_delimiters`) are accepted but ignored.

### Events

| name | description |
|:-----|:------------|
| `change` | Triggered when the value changes (user input or function update). |
| `copy` | Triggered when the user copies content. Carries copied text via `gradio.CopyData`. |

### User function

```python
def predict(value: str | None) -> str | None:
    return value

Metadata

Release files for gradio-somarkdown 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gradio-somarkdown 0.0.1
File Size Uploaded Provenance Actions
gradio_somarkdown-0.0.1.tar.gz 4.8 MB Without provenance Details for gradio_somarkdown-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gradio-somarkdown 0.0.1
File Interpreter ABI Platform Actions
gradio_somarkdown-0.0.1-py3-none-any.whl Python 3 none any Details for gradio_somarkdown-0.0.1-py3-none-any.whl

Total release size: 9.5 MB

Release files / gradio_somarkdown-0.0.1.tar.gz

Download URL gradio_somarkdown-0.0.1.tar.gz
Size 4.8 MB
Tags Source
SHA-256 checksum
How to use checksums
8282a31382bad99eca05690bba41c3ae34b9eb93ad103aa74ff9cfa87fb3911e
BLAKE2b-256 checksum
How to use checksums
599664ad7d78f2158e7bde9a3937b1747db11d7ecb5d739c82044b5448e941c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / gradio_somarkdown-0.0.1-py3-none-any.whl

Download URL gradio_somarkdown-0.0.1-py3-none-any.whl
Size 4.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
b0eb610e2730ad26f4d432ad39584ea70798a60be7f7122ded5b79ce5c5b0c86
BLAKE2b-256 checksum
How to use checksums
e14510617dd5346c219c34aa3d9e6386f98562fc2dac144dc5c032ce4d28c4bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Security for gradio-somarkdown 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page