@@ -657,7 +657,8 @@ QString Utils::Misc::htmlToMarkdown(QString text) {
657657 QRegularExpressionMatch match = codeBlockIt.next ();
658658 QString codeBlock = match.captured (0 );
659659 existingCodeBlocks.append (codeBlock);
660- QString placeholder = QStringLiteral (" ___CODE_BLOCK_PLACEHOLDER_%1___" ).arg (placeholderIndex++);
660+ QString placeholder =
661+ QStringLiteral (" ___CODE_BLOCK_PLACEHOLDER_%1___" ).arg (placeholderIndex++);
661662 text.replace (codeBlock, placeholder);
662663 }
663664
@@ -676,9 +677,9 @@ QString Utils::Misc::htmlToMarkdown(QString text) {
676677
677678 // Handle tables - must be done before other replacements
678679 // Convert HTML tables to Markdown tables
679- QRegularExpression tableRe (QStringLiteral ( " <table[^>]*?>(.*?)< \\ /table> " ),
680- QRegularExpression::CaseInsensitiveOption |
681- QRegularExpression::DotMatchesEverythingOption);
680+ QRegularExpression tableRe (
681+ QStringLiteral ( " <table[^>]*?>(.*?)< \\ /table> " ),
682+ QRegularExpression::CaseInsensitiveOption | QRegularExpression::DotMatchesEverythingOption);
682683 QRegularExpressionMatchIterator tableIt = tableRe.globalMatch (text);
683684
684685 while (tableIt.hasNext ()) {
@@ -702,8 +703,8 @@ QString Utils::Misc::htmlToMarkdown(QString text) {
702703
703704 // Extract cells (th or td)
704705 QRegularExpression cellRe (QStringLiteral (" <(th|td)[^>]*?>(.*?)<\\ /\\ 1>" ),
705- QRegularExpression::CaseInsensitiveOption |
706- QRegularExpression::DotMatchesEverythingOption);
706+ QRegularExpression::CaseInsensitiveOption |
707+ QRegularExpression::DotMatchesEverythingOption);
707708 QRegularExpressionMatchIterator cellIt = cellRe.globalMatch (rowHtml);
708709
709710 QStringList cells;
@@ -724,22 +725,25 @@ QString Utils::Misc::htmlToMarkdown(QString text) {
724725
725726 if (!cells.isEmpty ()) {
726727 columnCount = qMax (columnCount, cells.count ());
727- rows.append (QStringLiteral (" | " ) + cells.join (QStringLiteral (" | " )) + QStringLiteral (" |" ));
728+ rows.append (QStringLiteral (" | " ) + cells.join (QStringLiteral (" | " )) +
729+ QStringLiteral (" |" ));
728730
729731 // Add separator row after first row (header)
730732 if (isFirstRow) {
731733 QStringList separators;
732734 for (int i = 0 ; i < cells.count (); ++i) {
733735 separators.append (QStringLiteral (" ---" ));
734736 }
735- rows.append (QStringLiteral (" | " ) + separators.join (QStringLiteral (" | " )) + QStringLiteral (" |" ));
737+ rows.append (QStringLiteral (" | " ) + separators.join (QStringLiteral (" | " )) +
738+ QStringLiteral (" |" ));
736739 isFirstRow = false ;
737740 }
738741 }
739742 }
740743
741744 if (!rows.isEmpty ()) {
742- markdownTable = QStringLiteral (" \n\n " ) + rows.join (QStringLiteral (" \n " )) + QStringLiteral (" \n\n " );
745+ markdownTable =
746+ QStringLiteral (" \n\n " ) + rows.join (QStringLiteral (" \n " )) + QStringLiteral (" \n\n " );
743747 text.replace (tableMatch.captured (0 ), markdownTable);
744748 }
745749 }
@@ -779,23 +783,26 @@ QString Utils::Misc::htmlToMarkdown(QString text) {
779783 QStringLiteral (" \n\n > \\ 1\n\n " ));
780784
781785 // Handle horizontal rule
782- text.replace (QRegularExpression ( QStringLiteral ( " <hr.*?/?> " ),
783- QRegularExpression::CaseInsensitiveOption),
784- QStringLiteral (" \n\n ---\n\n " ));
786+ text.replace (
787+ QRegularExpression ( QStringLiteral ( " <hr.*?/?> " ), QRegularExpression::CaseInsensitiveOption),
788+ QStringLiteral (" \n\n ---\n\n " ));
785789
786790 // Handle images - must be done before links
787- text.replace (QRegularExpression (QStringLiteral (" <img[^>]+src=\" ([^\" ]+)\" [^>]*alt=\" ([^\" ]+)\" [^>]*>" ),
788- QRegularExpression::CaseInsensitiveOption),
789- QStringLiteral (" " ));
790- text.replace (QRegularExpression (QStringLiteral (" <img[^>]+alt=\" ([^\" ]+)\" [^>]*src=\" ([^\" ]+)\" [^>]*>" ),
791- QRegularExpression::CaseInsensitiveOption),
792- QStringLiteral (" " ));
791+ text.replace (
792+ QRegularExpression (QStringLiteral (" <img[^>]+src=\" ([^\" ]+)\" [^>]*alt=\" ([^\" ]+)\" [^>]*>" ),
793+ QRegularExpression::CaseInsensitiveOption),
794+ QStringLiteral (" " ));
795+ text.replace (
796+ QRegularExpression (QStringLiteral (" <img[^>]+alt=\" ([^\" ]+)\" [^>]*src=\" ([^\" ]+)\" [^>]*>" ),
797+ QRegularExpression::CaseInsensitiveOption),
798+ QStringLiteral (" " ));
793799 text.replace (QRegularExpression (QStringLiteral (" <img[^>]+src=\" ([^\" ]+)\" [^>]*>" ),
794800 QRegularExpression::CaseInsensitiveOption),
795801 QStringLiteral (" " ));
796802
797803 // Handle code blocks with language first
798- text.replace (QRegularExpression (QStringLiteral (" <pre[^>]*><code[^>]+class=\" [^\" ]*language-([^\"\\ s]+)[^\" ]*\" [^>]*>(.+?)<\\ /code><\\ /pre>" ),
804+ text.replace (QRegularExpression (QStringLiteral (" <pre[^>]*><code[^>]+class=\" [^\" ]*language-([^"
805+ " \"\\ s]+)[^\" ]*\" [^>]*>(.+?)<\\ /code><\\ /pre>" ),
799806 QRegularExpression::CaseInsensitiveOption |
800807 QRegularExpression::DotMatchesEverythingOption),
801808 QStringLiteral (" \n\n ```\\ 1\n\\ 2\n ```\n\n " ));
@@ -882,14 +889,18 @@ QString Utils::Misc::htmlToMarkdown(QString text) {
882889 QStringLiteral (" [\\ 2](\\ 1)" ));
883890
884891 // Handle div and span (just extract content)
885- text.replace (QRegularExpression (QStringLiteral (" <div.*?>" ), QRegularExpression::CaseInsensitiveOption),
886- QStringLiteral (" \n " ));
887- text.replace (QRegularExpression (QStringLiteral (" <\\ /div>" ), QRegularExpression::CaseInsensitiveOption),
888- QStringLiteral (" \n " ));
889- text.replace (QRegularExpression (QStringLiteral (" <span.*?>" ), QRegularExpression::CaseInsensitiveOption),
890- QStringLiteral (" " ));
891- text.replace (QRegularExpression (QStringLiteral (" <\\ /span>" ), QRegularExpression::CaseInsensitiveOption),
892- QStringLiteral (" " ));
892+ text.replace (
893+ QRegularExpression (QStringLiteral (" <div.*?>" ), QRegularExpression::CaseInsensitiveOption),
894+ QStringLiteral (" \n " ));
895+ text.replace (
896+ QRegularExpression (QStringLiteral (" <\\ /div>" ), QRegularExpression::CaseInsensitiveOption),
897+ QStringLiteral (" \n " ));
898+ text.replace (
899+ QRegularExpression (QStringLiteral (" <span.*?>" ), QRegularExpression::CaseInsensitiveOption),
900+ QStringLiteral (" " ));
901+ text.replace (
902+ QRegularExpression (QStringLiteral (" <\\ /span>" ), QRegularExpression::CaseInsensitiveOption),
903+ QStringLiteral (" " ));
893904
894905 // Handle paragraphs
895906 text.replace (QRegularExpression (QStringLiteral (" <p.*?>(.+?)</p>" ),
@@ -898,8 +909,8 @@ QString Utils::Misc::htmlToMarkdown(QString text) {
898909 QStringLiteral (" \n\n\\ 1\n\n " ));
899910
900911 // Remove any remaining HTML tags
901- text.remove (QRegularExpression ( QStringLiteral ( " <[^>]+> " ),
902- QRegularExpression::CaseInsensitiveOption));
912+ text.remove (
913+ QRegularExpression ( QStringLiteral ( " <[^>]+> " ), QRegularExpression::CaseInsensitiveOption));
903914
904915 // Decode HTML entities manually to preserve linebreaks
905916 // Common HTML entities
0 commit comments