Skip to main content

Convert Markdown to BBCode using a custom Mistune renderer.

Project description

md2bbcode logo

md2bbcode

A wrapper and plugin for Mistune. It converts GitHub-flavored Markdown to Xenforo-flavored BBCode. Custom BBCodes made for RedGuides are included in bb_codes.xml.

Installation

You can install md2bbcode using pip:

pip install md2bbcode

Usage

After installation, you can use md2bbcode from the command line:

md2bbcode README.md

If the markdown includes relative images or other assets, you can use the --domain flag to prepend a domain to the relative URLs:

md2bbcode README.md --domain https://raw.githubusercontent.com/RedGuides/md2bbcode/main/

Debug Mode

You can use the --debug flag to save intermediate results to files for debugging:

md2bbcode README.md --debug

Development

If you want to contribute to md2bbcode or set up a development environment, follow these steps:

  1. Clone the repository:

    git clone https://github.com/RedGuides/md2bbcode.git
    cd md2bbcode
    
  2. Install Hatch, which is used for building and managing the project:

    pip install hatch
    
  3. Create a development environment and install dependencies:

    hatch env create
    
  4. Activate the development environment:

    hatch shell
    

renderers/bbcode.py

The custom plugin for Mistune, which converts AST to bbcode.[^1]

[^1]: Mistune does not convert Markdown HTML to AST, hence the need for html2bbcode.

Additional Tools

html2bbcode

Converts several HTML tags typically allowed in Markdown to BBCode.[^2]

[^2]: Currently used for post-processing mistune output, but there's a better way. See inside the file for a suggestion.

html2bbcode input_file.html

md2ast

For debugging Mistune's renderer, converts a Markdown file to AST (JSON format).

md2ast input.md output.json

Features Test

Here are a few GitHub-flavored Markdown features so you can use this README.md for testing:

  • Strikethrough: This text is struck through.

  • Superscript: This text is normal and this is superscript.

  • Table:

    Syntax Description
    Header Title
    Paragraph Text

Todo

  • refactor html2bbcode
  • update for new Xenforo 2.3 and 2.4 BBCode

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

md2bbcode-0.1.0.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

md2bbcode-0.1.0-py2.py3-none-any.whl (23.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file md2bbcode-0.1.0.tar.gz.

File metadata

  • Download URL: md2bbcode-0.1.0.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.2

File hashes

Hashes for md2bbcode-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b4b1d67d16620594f99eb1140137e569c0ae5180865b283eebf0e5cee105086c
MD5 52830f6db04a272b8daa145e68da7cb5
BLAKE2b-256 8851dff51d45a8f9fff48bc8e399574e44953d4f3b29d1bba7288141f19b62f3

See more details on using hashes here.

File details

Details for the file md2bbcode-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for md2bbcode-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1b78f0d7f6c2ff1ae4bebc094cad5682a839ac1e94fa094d0ba236d6477c7eea
MD5 97c58dd672c4c11631767e4b73c646b6
BLAKE2b-256 ff0ffb1400ee0aa4e2170ff01c9c2f1e4395f503ef449e3b413d9abcb5a6607b

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