export function formatHTMLContent(htmlContent: string): string {
    return htmlContent
        .replace(/<h1>/g, '<h1 style="color: var(--color-text-primary); text-indent: 5px; font-size: 28px; font-weight: bold; text-align: left; margin-vertical: 10px;">')
        .replace(/<p>/g, '<p style="color: var(--color-editor-text); text-indent: 30px; font-size: 16px; line-height: 22px; margin-vertical: 5px;">')
        .replace(/<blockquote>/g, '<blockquote style="border-left-width: 4px; border-left-color: var(--color-gray-light); padding-left: 10px; font-style: italic; color: var(--color-text-dimmed);">');
}

export function textContentToHtml(content: string): string {
    const paragraphs: string[] = content
        .split(/\n+/)
        .map((paragraph: string) => paragraph.trim())
        .filter((paragraph: string) => paragraph.length > 0);
    
    return paragraphs
        .map((paragraph: string) => `<p>${paragraph}</p>`)
        .join('');
}

export function htmlToText(html: string): string {
    return html
        .replace(/<br\s*\/?>/gi, '\n')
        .replace(/<\/?(p|h[1-6]|div)(\s+[^>]*)?>/gi, '\n')
        .replace(/<\/?[^>]+(>|$)/g, '')
        .replace(/(\n\s*){2,}/g, '\n\n')
        .replace(/^\s+|\s+$|(?<=\s)\s+/g, '')
        .trim();
}
