Skip to content

Commit 2e802aa

Browse files
Add blockquote support to VS Code to Beehiiv converter (#114)
### Motivation - Convert Markdown blockquotes into Beehiiv-compatible blockquote figures so the VS Code → Beehiiv workflow preserves quoted content correctly. ### Description - Add a `BLOCKQUOTE_STYLE` constant and a `BLOCKQUOTE` handling branch inside `convertMarkdownToBeehiiv` in `vscode-to-beehiiv.html`. - Emit a `<figure data-variant="2" data-type="blockquoteFigure">` wrapper containing a `<blockquote>` with one or more `<p data-id=...>` paragraphs. - Preserve inline HTML and formatting in quote paragraphs and run the same link (`target`, `rel`, `class`) and code language normalization as other blocks. - Handle blockquotes that contain no `<p>` by creating a paragraph from the blockquote text. ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_699372e3cd3483258520f497129f89aa)
1 parent 1f86e54 commit 2e802aa

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

vscode-to-beehiiv.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ <h2>Beehiiv output</h2>
120120

121121
const BLOCK_STYLE = 'font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);';
122122
const HEADING_STYLE = BLOCK_STYLE.replace('font-weight: 400; ', '');
123+
const BLOCKQUOTE_STYLE = 'font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-line: none; text-decoration-thickness: auto; text-decoration-style: solid; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);';
123124

124125
const updateStatus = (message) => {
125126
status.textContent = message;
@@ -211,6 +212,45 @@ <h2>Beehiiv output</h2>
211212
return;
212213
}
213214

215+
if (node.tagName === 'BLOCKQUOTE') {
216+
const figure = document.createElement('figure');
217+
figure.setAttribute('data-id', crypto.randomUUID());
218+
figure.setAttribute('data-variant', '2');
219+
figure.setAttribute('data-type', 'blockquoteFigure');
220+
figure.setAttribute('style', BLOCKQUOTE_STYLE);
221+
222+
const quote = document.createElement('blockquote');
223+
224+
const quoteParagraphs = Array.from(node.querySelectorAll('p'));
225+
if (quoteParagraphs.length === 0) {
226+
const paragraph = document.createElement('p');
227+
paragraph.textContent = node.textContent.trim();
228+
quoteParagraphs.push(paragraph);
229+
}
230+
231+
quoteParagraphs.forEach((sourceParagraph) => {
232+
const paragraph = document.createElement('p');
233+
paragraph.setAttribute('data-id', crypto.randomUUID());
234+
paragraph.innerHTML = sourceParagraph.innerHTML;
235+
236+
paragraph.querySelectorAll('a').forEach(anchor => {
237+
anchor.setAttribute('target', '_blank');
238+
anchor.setAttribute('rel', 'noopener noreferrer nofollow');
239+
anchor.setAttribute('class', 'link');
240+
});
241+
242+
paragraph.querySelectorAll('code').forEach(code => {
243+
normalizeCodeLanguage(code);
244+
});
245+
246+
quote.appendChild(paragraph);
247+
});
248+
249+
figure.appendChild(quote);
250+
blocks.push(figure.outerHTML);
251+
return;
252+
}
253+
214254
if (node.tagName.startsWith('H')) {
215255
const level = Number.parseInt(node.tagName.replace('H', ''), 10);
216256
const heading = document.createElement(node.tagName.toLowerCase());

0 commit comments

Comments
 (0)