Commit c03c9da
authored
Fix Beehiiv markdown conversion spacing issues (#124)
### Motivation
- Markdown parsed from VS Code was producing extra empty paragraph elements and trailing newlines in code blocks, which resulted in too many blank lines and structurally odd HTML when pasted into Beehiiv.
### Description
- Added `isEmptyParagraph` to drop empty `<p>` nodes produced by the Markdown parser so blank paragraphs are not emitted.
- Changed first-block detection to set `data-pm-slice` on the first emitted block after filtering using `blocks.length === 0` instead of the original node index logic.
- Trimmed a trailing newline from fenced code block content with `code.textContent = code.textContent.replace(/\n$/, '');` to avoid extra blank lines inside `<pre><code>` output.
- Emit lists as top-level `<ul>`/`<ol>` elements (creating `list` via `document.createElement(node.tagName.toLowerCase())`) instead of wrapping them inside a `<p>`, which prevented extra spacing between list items.
------
[Codex Task](https://chatgpt.com/codex/tasks/task_e_69c542e1766483259b2c3d0256f3447d)1 parent 03e7eba commit c03c9da
1 file changed
Lines changed: 21 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
141 | 151 | | |
142 | 152 | | |
143 | 153 | | |
| |||
167 | 177 | | |
168 | 178 | | |
169 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
170 | 184 | | |
171 | 185 | | |
172 | | - | |
| 186 | + | |
173 | 187 | | |
174 | 188 | | |
175 | 189 | | |
| |||
197 | 211 | | |
198 | 212 | | |
199 | 213 | | |
| 214 | + | |
200 | 215 | | |
201 | 216 | | |
202 | 217 | | |
203 | 218 | | |
204 | 219 | | |
205 | 220 | | |
206 | 221 | | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
212 | 227 | | |
213 | 228 | | |
214 | 229 | | |
| |||
0 commit comments