You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Addresses #69 and #66 by documenting expected behavior:
- Explains paragraph spacing is standard markdown (blank lines between paragraphs)
- Documents line breaks vs paragraphs behavior
- Provides clear examples of maxConsecutiveNewlines option usage
- Shows how to control consecutive newlines for different use cases
Both issues are by-design behavior, not bugs. The maxConsecutiveNewlines
option (default: 3) already provides the control users need.
In standard Markdown, paragraphs are separated by blank lines. This library follows this convention, so HTML block elements like `<p>`, `<div>`, `<h1>`, etc. are surrounded by blank lines in the output.
237
+
238
+
**Example:**
239
+
240
+
```ts
241
+
const html =`<p>Hello</p><p>World</p><p>!</p>`;
242
+
const markdown =NodeHtmlMarkdown.translate(html);
243
+
console.log(markdown);
244
+
// Output:
245
+
// Hello
246
+
//
247
+
// World
248
+
//
249
+
// !
250
+
```
251
+
252
+
This is the expected behavior and produces valid, readable Markdown. If you need tighter spacing, consider using line breaks instead of paragraphs.
253
+
254
+
### Line Breaks vs Paragraphs
255
+
256
+
-**Paragraphs** (`<p>`) create blank lines between content (standard Markdown behavior)
257
+
-**Line breaks** (`<br>`) create single line breaks with two trailing spaces (Markdown line break syntax)
258
+
259
+
**Example:**
260
+
261
+
```ts
262
+
// Using line breaks
263
+
const html =`<p>Line 1<br>Line 2<br>Line 3</p>`;
264
+
const markdown =NodeHtmlMarkdown.translate(html);
265
+
console.log(markdown);
266
+
// Output:
267
+
// Line 1
268
+
// Line 2
269
+
// Line 3
270
+
```
271
+
272
+
### Controlling Consecutive Newlines
273
+
274
+
The `maxConsecutiveNewlines` option (default: `3`) limits how many consecutive newlines appear in the output. This helps keep the Markdown clean and prevents excessive whitespace.
275
+
276
+
**Example with multiple `<br>` tags:**
277
+
278
+
```ts
279
+
// Default behavior - limits to 3 consecutive newlines
280
+
const html =`<p>a</p>${'<br>'.repeat(10)}<p>b</p>`;
0 commit comments