hongdown 0.1.0-dev.3 → 0.1.0-dev.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +283 -0
  2. package/package.json +8 -8
package/README.md ADDED
@@ -0,0 +1,283 @@
1
+ Hongdown
2
+ ========
3
+
4
+ [![crates.io][crates.io badge]][crates.io]
5
+ [![npm][npm badge]][npm]
6
+ [![GitHub Actions][GitHub Actions badge]][GitHub Actions]
7
+
8
+ Hongdown is a Markdown formatter that enforces [Hong Minhee's Markdown style]
9
+ conventions. The formatter is implemented in Rust using the [Comrak] library
10
+ for parsing. It produces consistently formatted Markdown output following
11
+ a distinctive style used across multiple projects including [Fedify], [LogTape],
12
+ and [Optique].
13
+
14
+ [crates.io badge]: https://img.shields.io/crates/v/hongdown?logo=rust
15
+ [crates.io]: https://crates.io/crates/hongdown
16
+ [npm badge]: https://img.shields.io/npm/v/hongdown?logo=npm
17
+ [npm]: https://www.npmjs.com/package/hongdown
18
+ [GitHub Actions badge]: https://github.com/dahlia/hongdown/actions/workflows/main.yaml/badge.svg
19
+ [GitHub Actions]: https://github.com/dahlia/hongdown/actions/workflows/main.yaml
20
+ [Hong Minhee's Markdown style]: ./AGENTS.md#markdown-style-guide
21
+ [Comrak]: https://comrak.ee/
22
+ [Fedify]: https://fedify.dev/
23
+ [LogTape]: https://logtape.org/
24
+ [Optique]: https://optique.dev/
25
+
26
+
27
+ Installation
28
+ ------------
29
+
30
+ ### npm
31
+
32
+ ~~~~ bash
33
+ npm install -g hongdown
34
+ ~~~~
35
+
36
+ ### mise
37
+
38
+ ~~~~ bash
39
+ mise use github:dahlia/hongdown
40
+ ~~~~
41
+
42
+ ### Cargo
43
+
44
+ ~~~~ bash
45
+ cargo install hongdown
46
+ ~~~~
47
+
48
+ ### Pre-built binaries
49
+
50
+ Pre-built binaries for Linux, macOS, and Windows are available on the
51
+ [GitHub Releases] page.
52
+
53
+ [GitHub Releases]: https://github.com/dahlia/hongdown/releases
54
+
55
+
56
+ Usage
57
+ -----
58
+
59
+ ### Basic usage
60
+
61
+ ~~~~ bash
62
+ # Format a file and print to stdout
63
+ hongdown input.md
64
+
65
+ # Format a file in place
66
+ hongdown --write input.md
67
+ hongdown -w input.md
68
+
69
+ # Format multiple files
70
+ hongdown -w *.md
71
+
72
+ # Check if files are formatted (exit 1 if not)
73
+ hongdown --check input.md
74
+ hongdown -c input.md
75
+
76
+ # Show diff of formatting changes
77
+ hongdown --diff input.md
78
+ hongdown -d input.md
79
+
80
+ # Read from stdin
81
+ echo "# Hello" | hongdown
82
+ hongdown --stdin < input.md
83
+
84
+ # Custom line width
85
+ hongdown --line-width 100 input.md
86
+ ~~~~
87
+
88
+ ### Disable directives
89
+
90
+ Hongdown supports special HTML comments to disable formatting for specific
91
+ sections of your document:
92
+
93
+ ~~~~ markdown
94
+ <!-- hongdown-disable-file -->
95
+ This entire file will not be formatted.
96
+ ~~~~
97
+
98
+ ~~~~ markdown
99
+ <!-- hongdown-disable-next-line -->
100
+ This line preserves its spacing.
101
+
102
+ The next line will be formatted normally.
103
+ ~~~~
104
+
105
+ ~~~~ markdown
106
+ <!-- hongdown-disable-next-section -->
107
+ Everything here is preserved as-is
108
+ until the next heading (h1 or h2).
109
+
110
+ Next heading
111
+ ------------
112
+
113
+ This section will be formatted normally.
114
+ ~~~~
115
+
116
+ ~~~~ markdown
117
+ <!-- hongdown-disable -->
118
+ This section is not formatted.
119
+ <!-- hongdown-enable -->
120
+ This section is formatted again.
121
+ ~~~~
122
+
123
+ ### Configuration file
124
+
125
+ Hongdown looks for a `.hongdown.toml` file in the current directory and
126
+ parent directories. You can also specify a configuration file explicitly
127
+ with the `--config` option.
128
+
129
+ ~~~~ toml
130
+ # File patterns (glob syntax)
131
+ include = ["*.md", "docs/**/*.md"] # Files to format
132
+ exclude = ["node_modules/**"] # Files to skip
133
+
134
+ # Formatting options
135
+ line_width = 80
136
+
137
+ [heading]
138
+ setext_h1 = true # Use === underline for h1
139
+ setext_h2 = true # Use --- underline for h2
140
+
141
+ [list]
142
+ unordered_marker = "-" # "-", "*", or "+"
143
+ leading_spaces = 1 # Spaces before marker
144
+ trailing_spaces = 2 # Spaces after marker
145
+ indent_width = 4 # Indentation for nested items
146
+
147
+ [ordered_list]
148
+ odd_level_marker = "." # "1." at odd nesting levels
149
+ even_level_marker = ")" # "1)" at even nesting levels
150
+ pad = "start" # "start" or "end" for number alignment
151
+ indent_width = 4 # Indentation for nested items
152
+
153
+ [code_block]
154
+ fence_char = "~" # "~" or "`"
155
+ min_fence_length = 4 # Minimum fence length
156
+ space_after_fence = true # Space between fence and language
157
+ ~~~~
158
+
159
+ When `include` patterns are configured, you can run Hongdown without
160
+ specifying files:
161
+
162
+ ~~~~ bash
163
+ # Format all files matching include patterns
164
+ hongdown --write
165
+
166
+ # Check all files matching include patterns
167
+ hongdown --check
168
+ ~~~~
169
+
170
+ CLI options override configuration file settings:
171
+
172
+ ~~~~ bash
173
+ # Use config file but override line width
174
+ hongdown --line-width 100 input.md
175
+
176
+ # Use specific config file
177
+ hongdown --config /path/to/.hongdown.toml input.md
178
+ ~~~~
179
+
180
+
181
+ Style rules
182
+ -----------
183
+
184
+ Hongdown enforces the following conventions:
185
+
186
+ ### Headings
187
+
188
+ - Level 1 and 2 use Setext-style (underlined with `=` or `-`)
189
+ - Level 3+ use ATX-style (`###`, `####`, etc.)
190
+
191
+ ~~~~ markdown
192
+ Document Title
193
+ ==============
194
+
195
+ Section
196
+ -------
197
+
198
+ ### Subsection
199
+ ~~~~
200
+
201
+ ### Lists
202
+
203
+ - Unordered lists use ` - ` (space-hyphen-two spaces)
204
+ - Ordered lists use `1.` format
205
+ - 4-space indentation for nested items
206
+
207
+ ~~~~ markdown
208
+ - First item
209
+ - Second item
210
+ - Nested item
211
+ ~~~~
212
+
213
+ ### Code blocks
214
+
215
+ - Fenced with four tildes (`~~~~`)
216
+ - Language identifier on the opening fence
217
+
218
+ ~~~~~ text
219
+ ~~~~ rust
220
+ fn main() {
221
+ println!("Hello, world!");
222
+ }
223
+ ~~~~
224
+ ~~~~~
225
+
226
+ ### Line wrapping
227
+
228
+ - Lines wrap at approximately 80 display columns
229
+ - East Asian wide characters are counted as 2 columns
230
+ - Long words that cannot be broken are preserved
231
+
232
+ ### Links
233
+
234
+ - External URLs are converted to reference-style links
235
+ - References are placed at the end of each section
236
+ - Relative/local URLs remain inline
237
+
238
+ ~~~~ markdown
239
+ See the [documentation] for more details.
240
+
241
+ [documentation]: https://example.com/docs
242
+ ~~~~
243
+
244
+ ### Tables
245
+
246
+ - Pipes are aligned accounting for East Asian wide characters
247
+ - Minimum column width is maintained
248
+
249
+ See [SPEC.md] for the complete style specification.
250
+
251
+ [SPEC.md]: SPEC.md
252
+
253
+
254
+ Library usage
255
+ -------------
256
+
257
+ Hongdown can also be used as a Rust library:
258
+
259
+ ~~~~ rust
260
+ use hongdown::{format, Options};
261
+
262
+ let input = "# Hello World\nThis is a paragraph.";
263
+ let options = Options::default();
264
+ let output = format(input, &options).unwrap();
265
+ println!("{}", output);
266
+ ~~~~
267
+
268
+
269
+ Etymology
270
+ ---------
271
+
272
+ The name *Hongdown* is a portmanteau of *Hong* (from Hong Minhee, the author)
273
+ and *Markdown*. It also sounds like the Korean word *hongdapda* (홍답다),
274
+ meaning “befitting of Hong” or “Hong-like.”
275
+
276
+
277
+ License
278
+ -------
279
+
280
+ Distributed under the [GPL-3.0-or-later]. See *[LICENSE]* for more information.
281
+
282
+ [GPL-3.0-or-later]: https://www.gnu.org/licenses/gpl-3.0.html
283
+ [LICENSE]: ./LICENSE
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "hongdown",
3
- "version": "0.1.0-dev.3",
3
+ "version": "0.1.0-dev.8+4f6b2b27",
4
4
  "type": "module",
5
5
  "description": "A Markdown formatter that enforces Hong Minhee's Markdown style conventions",
6
6
  "license": "GPL-3.0-or-later",
7
7
  "author": "Hong Minhee <hong@minhee.org>",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "https://github.com/dahlia/hongdown"
10
+ "url": "git+https://github.com/dahlia/hongdown.git"
11
11
  },
12
12
  "homepage": "https://github.com/dahlia/hongdown",
13
13
  "keywords": [
@@ -27,11 +27,11 @@
27
27
  "node": ">=18"
28
28
  },
29
29
  "optionalDependencies": {
30
- "@hongdown/darwin-arm64": "0.0.0",
31
- "@hongdown/darwin-x64": "0.0.0",
32
- "@hongdown/linux-arm64": "0.0.0",
33
- "@hongdown/linux-x64": "0.0.0",
34
- "@hongdown/win32-arm64": "0.0.0",
35
- "@hongdown/win32-x64": "0.0.0"
30
+ "@hongdown/darwin-arm64": "0.1.0-dev.8+4f6b2b27",
31
+ "@hongdown/darwin-x64": "0.1.0-dev.8+4f6b2b27",
32
+ "@hongdown/linux-arm64": "0.1.0-dev.8+4f6b2b27",
33
+ "@hongdown/linux-x64": "0.1.0-dev.8+4f6b2b27",
34
+ "@hongdown/win32-arm64": "0.1.0-dev.8+4f6b2b27",
35
+ "@hongdown/win32-x64": "0.1.0-dev.8+4f6b2b27"
36
36
  }
37
37
  }