Skip to content

Instantly share code, notes, and snippets.

@Trunk89
Last active May 7, 2025 15:15
Show Gist options
  • Save Trunk89/74a0f761bb1f8c4da9647f998c8c4f93 to your computer and use it in GitHub Desktop.
Save Trunk89/74a0f761bb1f8c4da9647f998c8c4f93 to your computer and use it in GitHub Desktop.
case 'li': {
const parentTag = el.parentElement?.tagName.toLowerCase();
const isOrdered = parentTag === 'ol';
const isUnordered = parentTag === 'ul';
// Use placeholder marker — we'll replace it in `ol` later
const marker = isUnordered ? '-' : '1.';
// Render children with proper formatting
const content = convertNodeToPlainText(el).trim();
const lines = content.split('\n');
// Format first line with marker, and indent the rest
const formatted = lines.map((line, i) =>
i === 0 ? `${marker} ${line}` : ` ${line}`
).join('\n');
return `${formatted}\n`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment