Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions vscode-to-beehiiv.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ <h2>Beehiiv output</h2>

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);';
const HEADING_STYLE = BLOCK_STYLE.replace('font-weight: 400; ', '');
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);';

const updateStatus = (message) => {
status.textContent = message;
Expand Down Expand Up @@ -211,6 +212,45 @@ <h2>Beehiiv output</h2>
return;
}

if (node.tagName === 'BLOCKQUOTE') {
const figure = document.createElement('figure');
figure.setAttribute('data-id', crypto.randomUUID());
figure.setAttribute('data-variant', '2');
figure.setAttribute('data-type', 'blockquoteFigure');
figure.setAttribute('style', BLOCKQUOTE_STYLE);

const quote = document.createElement('blockquote');

const quoteParagraphs = Array.from(node.querySelectorAll('p'));
if (quoteParagraphs.length === 0) {
const paragraph = document.createElement('p');
paragraph.textContent = node.textContent.trim();
quoteParagraphs.push(paragraph);
}

quoteParagraphs.forEach((sourceParagraph) => {
const paragraph = document.createElement('p');
paragraph.setAttribute('data-id', crypto.randomUUID());
paragraph.innerHTML = sourceParagraph.innerHTML;

paragraph.querySelectorAll('a').forEach(anchor => {
anchor.setAttribute('target', '_blank');
anchor.setAttribute('rel', 'noopener noreferrer nofollow');
anchor.setAttribute('class', 'link');
});

paragraph.querySelectorAll('code').forEach(code => {
normalizeCodeLanguage(code);
});

quote.appendChild(paragraph);
});

figure.appendChild(quote);
blocks.push(figure.outerHTML);
return;
}

if (node.tagName.startsWith('H')) {
const level = Number.parseInt(node.tagName.replace('H', ''), 10);
const heading = document.createElement(node.tagName.toLowerCase());
Expand Down