Last active
May 7, 2025 15:15
-
-
Save Trunk89/74a0f761bb1f8c4da9647f998c8c4f93 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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