Convert Markdown to BBCode using a custom Mistune renderer.
Project description
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:
-
Clone the repository:
git clone https://github.com/RedGuides/md2bbcode.git cd md2bbcode
-
Install Hatch, which is used for building and managing the project:
pip install hatch
-
Create a development environment and install dependencies:
hatch env create
-
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
Built Distribution
File details
Details for the file md2bbcode-1.0.3.tar.gz
.
File metadata
- Download URL: md2bbcode-1.0.3.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0809412b6fafa0ef41a6e94cfc584f29dc4f79b8f60a63c48f983f0a477a3be |
|
MD5 | 16f33e94d1a7c9d8532b6dae9f7bc494 |
|
BLAKE2b-256 | 02eb8e7836c1affa7dd5eb261f449a102d20427dbf8a0ff97f227faed440fcf2 |
File details
Details for the file md2bbcode-1.0.3-py2.py3-none-any.whl
.
File metadata
- Download URL: md2bbcode-1.0.3-py2.py3-none-any.whl
- Upload date:
- Size: 22.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 495cb2bdf507edcdf7b25c2c77064142f40febca93334865f2380c15f693f7a3 |
|
MD5 | 49a0f8b7631b2a82e95e2e0a3ef262ed |
|
BLAKE2b-256 | 8a8be462fddc7b5bf617e3c906c117a88bcb113963bc84aae7bddc3e925dbe63 |