A utility to clean and convert MD files to ASCII.
Project description
MDCleaner
A utility to clean and convert MD files to ASCII.
Installation
You can install MDCleaner via pip:
pip install mdcleaner
Usage
After installation, you can use the package in your Python script:
from mdcleaner import clean_md
cleaned_content = clean_md("path_to_md_file.md")
print(cleaned_content)
Features
- Automatically detects file encoding.
- Converts non-ASCII characters to their closest ASCII representation.
- Provides warnings for unmatched templates, ensuring placeholders without corresponding variables are retained as-is.
- Handles improperly formatted templates, like unmatched curly braces {, and gives a clear warning while returning the content as-is.
Using the Formatted Option
Imagine you have an MD file named sample.md
with the following content:
This is a test: {my_variable}
In your script, you can replace the {my_variable}
placeholder with the value of a variable defined in your script:
from mdcleaner import clean_md
my_variable = "Hello, World!"
# Read and format the content of "sample.md"
cleaned_content = clean_md("sample.md", formatted=True)
print(cleaned_content) # This will print: "This is a test: Hello, World!"
By setting the formatted
option to True
, any placeholders inside {}
in your MD file will be replaced by the corresponding variables in your script.
If a placeholder doesn't have a corresponding variable in your script, a warning will be logged, and the placeholder will be retained in the output.
Contributing
If you find any bugs or want to propose a new feature, please open an issue or submit a pull request.
License
This project is licensed under the MIT License. See the LICENSE.txt file for details.
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 mdcleaner-0.1.2.tar.gz
.
File metadata
- Download URL: mdcleaner-0.1.2.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93a1649d227cbf4abd2bcc1510caf58998b95dbf80eeba8d6f7ae44d8f07bbc7 |
|
MD5 | 01a940764c71c47bf6cf2350a970051b |
|
BLAKE2b-256 | f11b72405c868a8190a3af60ee1d4b14c7db219bb3099aac7f6fd5c0e04ffd3f |
File details
Details for the file mdcleaner-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: mdcleaner-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8a2359a8d58572ae869efecae9b553d2a3503aeb24ca794f1a6aa42c9f259dd |
|
MD5 | 8640195a1e38ab52276c5b09d3a02027 |
|
BLAKE2b-256 | a0d1d2dbb6df9550c1095133dfef9b83feed1909a88d4ee1cc55ddf4b8f582db |