Hongdown
Hongdown is a Markdown formatter that enforces Hong Minhee's Markdown style conventions. The formatter is implemented in Rust using the comrak library for parsing. It produces consistently formatted Markdown output following a distinctive style used across multiple projects including Fedify, Hollo, and Vertana.
The name Hongdown is a portmanteau of Hong (from Hong Minhee, the author) and Markdown. It also sounds like the Korean word hongdapda (홍답다), meaning "befitting of Hong" or "Hong-like."
Installation
From source
Usage
Basic usage
# Format a file and print to stdout
# Format a file in place
# Format multiple files
# Check if files are formatted (exit 1 if not)
# Show diff of formatting changes
# Read from stdin
|
# Custom line width
Disable directives
Hongdown supports special HTML comments to disable formatting for specific sections of your document:
This entire file will not be formatted.
This line preserves its spacing.
The next line will be formatted normally.
Everything here is preserved as-is
until the next heading (h1 or h2).
Next heading
This section will be formatted normally.
This section is not formatted.
This section is formatted again.
Configuration file
Hongdown looks for a .hongdown.toml file in the current directory and
parent directories. You can also specify a configuration file explicitly
with the --config option.
= 80
[]
= true # Use === underline for h1
= true # Use --- underline for h2
[]
= "-" # "-", "*", or "+"
= 1 # Spaces before marker
= 2 # Spaces after marker
= 4 # Indentation for nested items
[]
= "." # "1." at odd nesting levels
= ")" # "1)" at even nesting levels
[]
= "~" # "~" or "`"
= 4 # Minimum fence length
= true # Space between fence and language
CLI options override configuration file settings:
# Use config file but override line width
# Use specific config file
Style rules
Hongdown enforces the following conventions:
Headings
- Level 1 and 2 use Setext-style (underlined with
=or-) - Level 3+ use ATX-style (
###,####, etc.)
Document Title
==============
Section
Lists
- Unordered lists use
-(space-hyphen-two spaces) - Ordered lists use
1.format - 4-space indentation for nested items
- - -
Code blocks
- Fenced with four tildes (
~~~~) - Language identifier on the opening fence
~~~~ rust
fn main() {
println!("Hello, world!");
}
~~~~
Line wrapping
- Lines wrap at approximately 80 display columns
- East Asian wide characters are counted as 2 columns
- Long words that cannot be broken are preserved
Links
- External URLs are converted to reference-style links
- References are placed at the end of each section
- Relative/local URLs remain inline
See the [documentation] for more details.
Tables
- Pipes are aligned accounting for East Asian wide characters
- Minimum column width is maintained
See SPEC.md for the complete style specification.
Library usage
Hongdown can also be used as a Rust library:
use ;
let input = "# Hello World\nThis is a paragraph.";
let options = default;
let output = format.unwrap;
println!;
TODO
Phase 1: Core formatting
- Basic CLI with file input/output
- Front matter preservation (YAML/TOML)
- Headings (setext and ATX)
- Paragraphs with line wrapping
- Lists (ordered and unordered)
- Code blocks (fenced)
- Block quotes
- Inline formatting (emphasis, strong, code, links)
- Basic test suite
Phase 2: Extended syntax
- Tables with alignment
- Definition lists
- GitHub alerts/admonitions
- Footnotes
- Reference link collection and placement
Phase 3: Polish
- Configuration file support
- Config file parsing and discovery (
.hongdown.toml) -
line_widthoption -
[heading]section-
setext_h1option -
setext_h2option
-
-
[list]section-
unordered_markeroption -
leading_spacesoption -
trailing_spacesoption -
indent_widthoption
-
-
[ordered_list]section-
odd_level_markeroption -
even_level_markeroption
-
-
[code_block]section-
fence_charoption -
min_fence_lengthoption -
space_after_fenceoption
-
- Config file parsing and discovery (
- Check mode for CI integration
- Diff output mode
- Disable directives
- Edge case handling
- Performance optimization
License
Distributed under the GPL-3.0-or-later. See LICENSE for more information.