Skip to content

shachi-lab/md-formatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Markdown Formatter

🇯🇵 日本語版はこちら

A flexible command-line tool for normalizing and customizing Markdown styles.


✨ Features

  • Unify bold, italic, horizontal rules (hr), and list markers with your preferred symbols
  • Preserve code blocks completely
  • Remove unnecessary escape characters (\*, \\[ etc.) — optional
  • Clean up extra blank lines in lists (especially those generated by Notepad) — optional

⚙️ Installation

  1. Clone the repository

    git clone https://github.com/shachi-lab/md-formatter.git
    cd markdown-formatter
  2. Grant execution permission (Linux/macOS)

    chmod +x md_formatter.py
  3. (Optional) Create a symbolic link

    ln -s $(pwd)/md_formatter.py /usr/local/bin/mdfmt

💻 OS-specific instructions

Linux / macOS

  • You can make it executable and link it as shown above.

Windows

  • No need for chmod or symbolic links.
    Run directly from Python:
    python md_formatter.py input.md > output.md
  • Optionally, create a .bat file to use it as a shortcut command.

🧩 Usage Examples

Basic

# Format input.md and output to output.md
./md_formatter.py input.md > output.md

Custom options

# Set bold to '_', italic to '-', horizontal rule to '*', and list marker to '+'
./md_formatter.py \
  --bold _ \
  --italic - \
  --hr * \
  --list + \
  input.md > output.md
# Keep escape characters and disable list formatting
./md_formatter.py --no-del-escape --no-fix-list input.md > output.md
#### Format Markdown file and output to stdout
./md_formatter.py input.md > output.md
## Change italic to underscore, bold to *, and hr to *
./md_formatter.py --italic _ --bold * --hr * input.md

🧰 Options

Option Description Default
--bold {*, -, _} Select bold marker *
--italic {*, -, _} Select italic marker *
--hr {*, -, _} Select horizontal rule marker -
--list {*, -, +} Select list marker -
--no-del-escape Keep backslash-escaped characters false
--no-fix-list Disable list cleanup false

🧠 Behavior

  1. Code blocks

    • Sections wrapped by triple backticks ``` are preserved as-is.
  2. Escape character removal (--no-del-escape not specified)

    • Removes unnecessary \ before Markdown syntax (e.g. \*, \[, etc.)
  3. List formatting (--no-fix-list not specified)

    • Removes extra blank lines between list items inserted by Notepad.
  4. Horizontal rule conversion

    • Normalizes various hr markers like ---, ***, ___ to the selected symbol repeated three times.

🤝 Contributing

Bug reports and pull requests are welcome!

  1. Open an issue
  2. Fork and create a new branch
  3. Make changes and submit a pull request

📄 License

MIT License © [Shachi-lab]

About

Markdown formatter for CLI / Markdown整形ツール(記法の揺れを統一)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages