Skip to main content

A Markdown extension for rendering LaTeX math using Katex

Project description

About md_katex

Build Status

md_katex is a KaTeX plugin initially developed for use in personal blogs with Pelican. It focuses on rendering mathematical formulas directly in the browser using the KaTeX JavaScript library, rather than performing offline conversions.

Features

  • Client-Side Rendering: Unlike other plugins, md_katex does not convert formulas offline. Instead, the KaTeX JavaScript file in the browser handles the rendering, making the publishing process simpler and more efficient.

  • Supports Multiple Formula Delimiter Styles:

    • GitLab Style: Use $` and `$ for inline formulas, and ~~~math code blocks for block-level formulas.
    • Brackets Style: Use \( and \) for inline formulas, and \[ and \] for block-level formulas.
    • GitHub Style: Use $$ as both the opening and closing delimiters for block-level formulas.
  • Unified Output Format: After Markdown is converted to HTML, all formulas are standardized to use the Brackets style delimiters and are rendered via JavaScript.

Installation

First, ensure that you have the python-markdown library installed. Then, you can install this plugin using the following command:

pip install md_katex

The generated HTML will include KaTeX formulas, and you will need to load KaTeX JavaScript on the frontend to complete the rendering.

To ensure proper rendering, include the KaTeX script via a <script> tag in your HTML page. For example, using a CDN:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css" integrity="sha384-nB0miv6/jRmo5UMMR1wu3Gz6NLsoTkbqJghGIsx//Rlm+ZU03BU6SQNC66uf4l5+" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.js" integrity="sha384-7zkQWkzuo3B5mTepMUcHkMB5jZaolc2xDwL6VFqjFALcbeS9Ggm/Yr2r3Dy4lfFg" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/contrib/auto-render.min.js" integrity="sha384-43gviWU0YVjaDtb/GhzOouOXtZMP/7XUzwPTstBeZFe/+rCMvRwr4yROQP43s0Xk" crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

md_katex-0.2.1.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

md_katex-0.2.1-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file md_katex-0.2.1.tar.gz.

File metadata

  • Download URL: md_katex-0.2.1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for md_katex-0.2.1.tar.gz
Algorithm Hash digest
SHA256 d9655fd0529e9a6029d249f0034ad3f3eba881c393f1ddd54ef00ee75c093dd3
MD5 bd02580b4a99d216bb23deccb3c4cc8a
BLAKE2b-256 5e260b4bdfc45bdc0364da0329f7a4172dc93622c641ead0591d6a8e5b256695

See more details on using hashes here.

File details

Details for the file md_katex-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: md_katex-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for md_katex-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 009bdb4af81cfb34c529d34d23ed38a0e3d7b35af83b383671ffbc2e099a4f25
MD5 f382b2da1b41611b36e02e3d62d7c4ee
BLAKE2b-256 1bb2d0a14c60ce337fda91352ca9cde84a67fd0930baccfd6467f1c3738ba02d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page