Bug Report: Bad Markdown Formatting, Unnecessary LaTeX Math Invocation, and CommonMark Syntax Violations in Gemini Output

Bug Report and Markdown Encoding Syntax Issues in Google AI Studio and API

Dear Google employees and esteemed employees of its contractor companies. I would like to submit a bug report regarding the Google AI Studio platform. I observed these bugs in both the graphical user interface and while working with the API. These are issues and very serious flaws concerning the correctness of Markdown syntax and encoding, where the rules for the correct formatting of this standard are violated.

Unjustified Use of LaTeX Formatting and Incorrect Notation of the Greek Alphabet in Pharmacology and Receptors

I asked the artificial intelligence questions in the fields of pharmacology, drug effects, and the mechanisms of psychoactive substances involving various brain receptors. Although science recognizes hundreds of additional receptors, I am an expert in this field and understand it thoroughly. Visually, right within the Google AI Studio interface, the system displayed everything completely correctly. A fundamental problem arose, however, the moment I attempted to convert these outputs into HTML code. Initially, I assumed that the error likely lay in the HTML converters themselves. Ultimately, it turned out that the root cause was incorrectly generated Markdown, in which using LaTeX formatting was entirely unnecessary.

Similarly, in the domain of neurological receptors—whether concerning psychoactive substances such as cannabinoids and the active compounds of cannabis, or the effects of psychiatric medications—the Greek alphabet is frequently utilized, yet this alphabet was improperly formatted in the generated Markdown.

Failure of Converters and the Pandoc Tool on Linux When Processing Subscripts and Chemical Formulas

As a result, standard online Markdown-to-HTML converters failed to handle this notation, and even such a renowned tool as Pandoc failed. Pandoc is a command-line utility without a graphical user interface, primarily intended for Linux. As a true professional, I am a Linux user and do not use Windows—in fact, I barely even know what kind of operating system Windows is, because Linux is more than sufficient for all my work. Although Pandoc is primarily intended for Linux, it can presumably run on Windows as well, but I mention that only as an aside. Pandoc is thus a headless tool capable of converting Markdown into HTML.

In the end, however, it became clear that under these conditions, not even Pandoc functions properly. In reality, Pandoc was not to blame; rather, the mistake was made by the developers of Gemini and AI Studio themselves, because they failed to implement official rules for Greek alphabet notation and introduced LaTeX where it was completely unnecessary and where standard Markdown would have been perfectly adequate. This applies, for example, to superscripts, subscripts, or mathematical formulas. Subscripts in particular appear very frequently in chemical formulas. For chemical formulas, one merely needs a standard subscript; it is not at all necessary to employ complex LaTeX formatting when I am simply asking about an ordinary chemical reaction, for instance.

Expert Feedback from a Specialist’s Perspective and a Demand for Action from Development Teams and Management

I am an exceptionally, extremely intelligent and highly educated individual with deep interests across multiple scientific disciplines, primarily neuroscience, chemistry, and pharmacology. Yet in this situation, I suddenly find that I cannot convert the generated output into HTML code because the Markdown format is structured incorrectly and you are violating Markdown formatting standards, which represents a clear defect. You must fix this without exception. It is of utmost importance that you escalate this feedback to upper management, who should subsequently assign a sufficiently large team of engineers to comprehensively address and resolve all these shortcomings, as that is your direct responsibility.

Issue with the Excessive Generation of Headings and Subheadings in Gemini and NotebookLM Models for WordPress

Likewise, the system generated an unreasonably large number of headings and subheadings. While this issue does not pertain exclusively to Google AI Studio—as I have experienced the exact same difficulties in both Gemini and NotebookLM environments—it is another Google AI product generating an enormous quantity of headings and sublevels. In practice, this causes tremendous complications: when I use a table-of-contents generator in WordPress, the result is completely cluttered and creates an unbearable amount of bloat when trying to display all these redundant subheadings.

This creates unnecessary extra work for me, because when I publish an AI-generated article on my private personal website, the whole piece appears disorganized due to the presence of useless and unjustified headings and subheadings. This structure should be handled differently, rather than producing so many varied heading levels, as this is not an appropriate solution.

VPS Server Overload, PHP Process Failure, and Timeout Errors During Content Generation

For example, while publishing a rather lengthy article, the VPS server on which I host WordPress simply froze. A timeout error occurred, indicating that the server could no longer handle such a processing load. It was an extensive article with an excessive number of headings and subheadings, where the table-of-contents plugin caused an overload that crashed the corresponding PHP process. This entire behavior is thoroughly impractical; therefore, I kindly ask you to fix all of these issues. This is a systemic flaw, but all such serious defects can be corrected, which I consider very positive, so you have plenty of work ahead of you.

*********

Bug Report: Markdown Formatting Degradation, Unnecessary LaTeX Math Invocation, and CommonMark Syntax Violations in Gemini Output

Target: Google AI Studio / Gemini Model Family (Flash & Pro series)
Category: Output Formatting / Markdown & LaTeX Tokenization / Post-Processing
Severity: Medium (Leads to broken HTML rendering, parser crashes, and unreadable text in standard web/CMS pipelines)


1. Executive Summary

When generating scientific, biomedical, and structured explanatory text, Gemini frequently produces malformed Markdown and unnecessarily wraps plain inline terms into LaTeX math delimiters ($...$).

This causes two critical downstream issues:

  1. Broken Math/Symbol Rendering: Standard Markdown-to-HTML parsers without MathJax/KaTeX (e.g., standard Pandoc, CMS like WordPress, Odysee, Static Site Generators) fail to render terms like $\text{CB}_1$ or $\alpha_1$, displaying raw escaped delimiters like \(\text{CB}_1\) or missing subscripts completely.
  2. Structural Collapse of Lists and Quotes: The model frequently violates CommonMark standards by omitting blank lines before lists and blockquotes immediately following colons (:), causing HTML parsers to squash ordered/unordered lists and quotes into a single continuous, unformatted paragraph.

2. Detailed Issues and Concrete Examples

Issue A: Overuse of LaTeX Math Mode for Chemical/Biological Nomenclature

  • Observed Behavior: The model wraps simple biological receptors, chemical ions, and subscripts in LaTeX math mode instead of using native Unicode or standard semantic Markdown/HTML notation.
  • Problematic Output Examples from Gemini:
    • $\text{CB}_1$ and $\text{CB}_2$ (Cannabinoid receptors)
    • $\text{GABA}_A$
    • $Ca^{2+}$ and $Mg^{2+}$
  • Why this is problematic: These are not mathematical equations. In non-academic environments lacking active MathJax JavaScript engines, this output breaks and renders literal LaTeX code (\text{CB}_1).
  • Expected / Clean Behavior:
    • Use Unicode/subscript/superscript notation directly: CB₁, CB₂, GABA_A, Ca²⁺, Mg²⁺
    • OR standard Markdown/HTML tags: CB<sub>1</sub>, Ca<sup>2+</sup>.

Issue B: Inconsistent and Unnecessary LaTeX for Greek Alphabet Characters

  • Observed Behavior: The model arbitrarily mixes native Unicode Greek letters with LaTeX escape sequences within the same paragraph.

  • Problematic Output Example:

    • ...podjednotiek $\alpha_1$ a $\alpha_3$ alongside PPAR-γ (where gamma is Unicode, but alpha is in math mode).
  • Downstream Result: In rendered HTML, the browser displays:

    (najmä podjednotiek \(\alpha_1\) a \(\alpha_3\))

  • Expected Behavior: Greek letters should be emitted consistently as plain UTF-8 characters (α, β, γ, α₁, α₃) unless part of a complex standalone mathematical formula (e.g., integrals, fractions, matrices).


Issue C: Violation of CommonMark Blank-Line Precedence (List & Blockquote Flattening)

  • Observed Behavior: When a list or blockquote follows an introductory statement ending with a colon (:), the model frequently places the list or quote on the immediate next line without a blank line (\n\n) separation.

  • Problematic Output Example:

    Kanabinoidy pôsobia ako komplexné širokospektrálne analgetikum:
    1. **Cez $\text{CB}_1$ a inhibíciu glutamátu** vypínajú...
    2. **Cez moduláciu...**
    
    Pacienti liečení kanabisom často popisujú analgetický účinok veľmi špecificky:  
    > *„Bolesť tam technicky stále je...“*  
    THC teda neodpája...
    
  • Downstream Result: According to CommonMark and Pandoc parser rules, a list or blockquote directly attached to an open paragraph without a blank line (\n\n) is treated as inline paragraph text. In the rendered HTML, this completely destroys the structure and produces a single flattened line:

    Kanabinoidy pôsobia ako komplexné širokospektrálne analgetikum: 1. Cez CB1 a inhibíciu glutamátu vypínajú... 2. Cez moduláciu...
    ...veľmi špecificky: > „Bolesť tam technicky stále je...“ THC teda neodpája... (with raw > rendered as text).

  • Expected Behavior:
    The model must consistently enforce a blank line (\n\n) before:

    • Any ordered list (1., 2.)
    • Any unordered list (*, -, +)
    • Any blockquote (>)

Issue D: Deep Heading Hierarchy for Minor List Items

  • Observed Behavior: The model frequently defaults to using level 3 to 6 headings (###, ####) to emphasize minor itemized subsections inside already enumerated lists.
  • Impact: Downstream CMS platforms (e.g., WordPress, documentation portals) with Table of Contents (TOC) generators pick up dozens of these micro-headings, generating cluttered, broken navigation menus and unnecessarily triggering high regex backtracking limits during page assembly.
  • Expected Behavior: Use bold text paragraphs (**Bold title:**) or description lists for sub-points instead of nesting ### or #### headings under list items.

3. Impact on Developers & End Users

  1. Preprocessing Overhead: Developers must build extensive custom regex filters and Pandoc wrappers to sanitize Gemini’s Markdown output before it can be safely injected into web applications or CMS engines.
  2. Display Inconsistency: End users copying text into emails, documents, or websites get broken LaTeX markers (\(\text{...}\)) and jumbled lists that lose all line breaks.

4. Suggested Fixes / Recommendations for the Gemini Engineering Team

  1. System Prompt / RLHF Fine-Tuning for Markdown:
    • Penalize the generation of inline LaTeX ($...$) when the expression contains only plain alphanumeric labels, standard ion charges, or single Greek letters.
    • Prioritize native UTF-8 representations (α, β, γ, ₁, ₂, ²⁺) for chemical/biological terminology unless the user explicitly requests LaTeX format.
  2. Strict CommonMark Boundary Enforcement:
    • Ensure that the tokenizer / generation head always appends a double newline (\n\n) before emitting list indicators (^([0-9]+\.|\*|\-|\+) ) and blockquotes (^> ) following a paragraph ending with :.

Dear Google employees, I am helping you with testing and development. Enter these questions into Gemini 3.8 Flash. You will receive correct answers and proper rendering in the graphical user interface, but it will generate malformed Markdown that cannot be converted to HTML even by a tool as renowned as Pandoc. Pandoc is the best tool in the world in this category, yet even it cannot handle the conversion, because the issue does not lie within Pandoc.


  • Cannabis. THC. Does it have potent anti-inflammatory effects on the lungs in COVID-19 via CB2 receptors? Also via receptors other than CB2?
  • Cannabis. THC. Does it possess anti-inflammatory and neuroprotective properties in the brain during a COVID infection? Potent neuroprotective properties via inhibition/antagonism of glutamate / NMDA receptors?
  • Does a cytokine storm cause excitotoxicity? Are there also studies on generally slowing down excitotoxicity? Independent of COVID, as prevention against dementia and neurodegenerative processes in the brain, Alzheimer’s disease?
  • Are there also studies on mitigating excitotoxicity using THC and other cannabinoids? Prevention against dementia and neurodegenerative processes in the brain, Alzheimer’s disease?
  • How does cannabis affect patients with epilepsy? Does THC have a positive effect on glutamate, AMPA, and NMDA receptors for these patients, but a negative effect on GABA receptors? Are there cannabinoids that do not reduce the activity of GABA receptors?
  • In what way do THC and other cannabinoids relieve pain as an analgesic? Via glutamate receptors, opioid receptors, and other receptors?
  • A related topic regarding neuroprotective supplements for the brain: Magnesium L-threonate (Magtein). What is its chemical structure? How much more or less magnesium does it contain by weight compared to standard magnesium supplements? Proportionally to its weight, how much more magnesium reaches the body / brain compared to conventional magnesium supplements?
  • Rank all types of magnesium dietary supplements, organic and inorganic. Ratio of active ingredient weight vs. the amount that reaches the brain? Is there significant permeability into the brain for other supplements as well?
  • Magnesium N-acetyltaurate (ATA-Mg). Is it a precursor to taurine? Are potent neuroprotective properties against excitotoxicity among the main effects of taurine? Is this supported by extensive research? Is this also one of the reasons it is a suitable dietary supplement for seniors?
  • Magnesium L-threonate (Magtein). What is its chemical structure? How much more or less magnesium does it contain by weight compared to standard magnesium supplements? Proportionally to its weight, how much more magnesium reaches the body / brain compared to conventional magnesium supplements?
  • Rank all types of magnesium dietary supplements, organic and inorganic. Ratio of active ingredient weight vs. the amount that reaches the brain? Is there significant permeability into the brain for other supplements as well?
  • Magnesium N-acetyltaurate (ATA-Mg). Is it a precursor to taurine? Are potent neuroprotective properties against excitotoxicity among the main effects of taurine? Is this supported by extensive research? Is this also one of the reasons it is a suitable dietary supplement for seniors?

Pavol, I have been noticing poor markdown formatting on the desktop browser based Gemini outputs when it is instructed to return a markdown code block as well. Very similar to what you are describing. What is interesting is that when the outputs are viewed in the Gemini app, they are formatted correctly, and things displayed within the browser code block like\(\eta\) are correctly displayed as $\eta$ in the app.

Kelley

Thank you very much for providing additional valuable information about this bug.

(I personally use the Opera browser—which is based on Chromium—where this bug appeared).

Markdown Viewer Rendering Failure: PHP Variables ($) Erroneously Interpreted as KaTeX/LaTeX Equations

Problem Description: When requesting or generating PHP code in the Gemini web interface from this Google Workspace account, the markdown parser (LaTeX / KaTeX renderer) mistakes PHP variables containing the dollar sign (\() (e.g., \)periodo_id, \(_GET, \)_SESSION) for mathematical notation.

As a result, the viewer automatically injects escaping backslashes and parentheses (\( and \)) before variables in both the on-screen display and when using the Markdown block’s “Copy code” button, corrupting the code syntax.

Steps to Reproduce:

  1. Request any PHP code block containing standard variables from Gemini (e.g., \(variable =\)_POST['field'];).

  2. Observe how the rendered block alters the text and injects \( around the variable name.

  3. Copy the block to the clipboard and paste it into a text editor (the syntax error persists).

Impact: This severely disrupts the software development workflow by corrupting PHP syntax under this account. Notably, this error only occurs with this specific Google Workspace account and not with other personal accounts within the same organization, suggesting a bug tied to the frontend deployment rollout assigned to this user.

Requested Action: Fix the Markdown/LaTeX parser so that it ignores the $ sign inside triple-backtick code blocks (```php), or remove this account from the current web interface experiment/rollout group.

CLI command for run:

python3 script.py input.md output.html

Script

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import re
import subprocess
import sys

# Complete table of Greek letters and mathematical symbols for UTF-8 conversion
LATEX_SYMBOLS = {
    # Greek letters (lowercase)
    r'\alpha': 'α', r'\beta': 'β', r'\gamma': 'γ', r'\delta': 'δ',
    r'\epsilon': 'ε', r'\varepsilon': 'ε', r'\zeta': 'ζ', r'\eta': 'η',
    r'\theta': 'θ', r'\vartheta': 'θ', r'\iota': 'ι', r'\kappa': 'κ',
    r'\lambda': 'λ', r'\mu': 'μ', r'\nu': 'ν', r'\xi': 'ξ',
    r'\pi': 'π', r'\rho': 'ρ', r'\varrho': 'ρ', r'\sigma': 'σ',
    r'\tau': 'τ', r'\upsilon': 'υ', r'\phi': 'φ', r'\varphi': 'φ',
    r'\chi': 'χ', r'\psi': 'ψ', r'\omega': 'ω',
    # Greek letters (uppercase)
    r'\Gamma': 'Γ', r'\Delta': 'Δ', r'\Theta': 'Θ', r'\Lambda': 'Λ',
    r'\Xi': 'Ξ', r'\Pi': 'Π', r'\Sigma': 'Σ', r'\Phi': 'Φ',
    r'\Psi': 'Ψ', r'\Omega': 'Ω',
    # Mathematical operators and relations
    r'\approx': '≈',
    r'\sim': '~',
    r'\neq': '≠', r'\ne': '≠',
    r'\leq': '≤', r'\le': '≤',
    r'\geq': '≥', r'\ge': '≥',
    r'\times': '×',
    r'\cdot': '·',
    r'\pm': '±',
    r'\mp': '∓',
    r'\div': '÷',
    r'\infty': '∞',
    r'\degree': '°', r'\circ': '°',
    r'\rightarrow': '→', r'\to': '→',
    r'\leftarrow': '←',
    r'\Rightarrow': '⇒',
    r'\Leftarrow': '⇐',
    r'\leftrightarrow': '↔',
    r'\sum': '∑',
    r'\prod': '∏',
    r'\sqrt': '√'
}

def process_latex_content(content):
    """Converts the inside of a LaTeX formula into plain text / HTML tags."""
    content = content.strip()

    # 1. Handling LaTeX decimal comma: 44{,}5 -> 44,5
    content = re.sub(r'\{,\}', ',', content)

    # 2. LaTeX spaces (\, \; \quad \qquad)
    content = re.sub(r'\\(?:quad|qquad)', ' &nbsp; ', content)
    content = re.sub(r'\\[,;:!]', ' ', content)

    # 3. Brackets \left(, \right), \{, \}
    content = re.sub(r'\\(?:left|right)\s*([()\[\]|])', r'\1', content)
    content = re.sub(r'\\\{', '{', content)
    content = re.sub(r'\\\}', '}', content)

    # 4. Fractions: \frac{a}{b} -> (a / b)
    while re.search(r'\\frac\{([^{}]+)\}\{([^{}]+)\}', content):
        content = re.sub(r'\\frac\{([^{}]+)\}\{([^{}]+)\}', r'(\1 / \2)', content)

    # 5. Removal of text wrappers: \text{...}, \mathrm{...}
    # Using a while loop handles nested tags as well
    while re.search(r'\\(?:text|mathrm|operatorname)\{([^{}]*)\}', content):
        content = re.sub(r'\\(?:text|mathrm|operatorname)\{([^{}]*)\}', r'\1', content)

    # 6. Bold text: \mathbf{...}, \textbf{...} -> <strong>...</strong>
    while re.search(r'\\(?:mathbf|textbf)\{([^{}]*)\}', content):
        content = re.sub(r'\\(?:mathbf|textbf)\{([^{}]*)\}', r'<strong>\1</strong>', content)

    # 7. Italics: \mathit{...}, \textit{...} -> <em>...</em>
    while re.search(r'\\(?:mathit|textit)\{([^{}]*)\}', content):
        content = re.sub(r'\\(?:mathit|textit)\{([^{}]*)\}', r'<em>\1</em>', content)

    # 8. Replacing Greek letters and mathematical operators (\approx -> ≈)
    for latex_symbol, unicode_symbol in LATEX_SYMBOLS.items():
        content = re.sub(re.escape(latex_symbol) + r'(?![a-zA-Z])', unicode_symbol, content)

    # 9. Subscripts: _{xyz} or _x
    content = re.sub(r'_\{([^}]+)\}', r'<sub>\1</sub>', content)
    content = re.sub(r'_([0-9a-zA-Zα-ωΑ-Ω+-]+)', r'<sub>\1</sub>', content)

    # 10. Superscripts: ^{xyz} or ^x
    content = re.sub(r'\^\{([^}]+)\}', r'<sup>\1</sup>', content)
    content = re.sub(r'\^([0-9a-zA-Zα-ωΑ-Ω+-]+)', r'<sup>\1</sup>', content)

    # 11. Cleaning up extra curly braces and remaining backslashes
    content = re.sub(r'(?<![\\&a-zA-Z0-9])\{([^{}]+)\}', r'\1', content)
    content = content.replace('\\', '')

    # Space normalization
    content = re.sub(r'[ \t]+', ' ', content)
    return content.strip()

def latex_block_to_html(match):
    """Processes a standalone block formula $$...$$ into a centered paragraph."""
    content = process_latex_content(match.group(1))
    return f'\n\n<div class="math-display">\n{content}\n</div>\n\n'

def latex_inline_to_html(match):
    """Processes an inline formula $...$."""
    content = process_latex_content(match.group(1))
    return f'<span class="math-inline">{content}</span>'

def fix_and_prepare_markdown(text):
    # A) Conversion of block LaTeX formulas $$...$$ (must be done first!)
    text = re.sub(r'\$\$(.*?)\$\$', latex_block_to_html, text, flags=re.DOTALL)

    # B) Conversion of inline LaTeX formulas $...$ (within a single line only)
    text = re.sub(r'(?<!\$)\$(?!\$)([^\$\n]+?)(?<!\$)\$(?!\$)', latex_inline_to_html, text)

    # C) Fix blockquotes (>): ensures a blank line before and after blockquotes
    text = re.sub(r'([^\n])\n[ \t]*>', r'\1\n\n>', text)
    text = re.sub(r'(>[^\n]+)\n([^>\n\s])', r'\1\n\n\2', text)

    # D) Fix headings (#): ensures a blank line before headings
    text = re.sub(r'([^\n])\n[ \t]*(#{1,6}[ \t])', r'\1\n\n\2', text)

    # E) Smart fix for lists:
    lines = text.split('\n')
    new_lines = []
    list_pattern = re.compile(r'^[ \t]*(\d+\.|\*|\-|\+)[ \t]')
    in_list = False

    for i, line in enumerate(lines):
        is_item = bool(list_pattern.match(line))
        if is_item:
            if not in_list:
                if i > 0 and lines[i - 1].strip() != '':
                    new_lines.append('')
                in_list = True
        else:
            if line.strip() == '':
                in_list = False

        new_lines.append(line)

    return '\n'.join(new_lines)

def replace_subheadings_with_bold(html):
    def convert(match):
        content = match.group(2).strip()
        clean_content = re.sub(r'</?(?:strong|b)\b[^>]*>', '', content, flags=re.IGNORECASE)
        return f'<p><strong>{clean_content}</strong></p>'

    return re.sub(r'<h([3-6])\b[^>]*>(.*?)</h\1>', convert, html, flags=re.DOTALL | re.IGNORECASE)

def clean_spaces_in_html(html):
    html = re.sub(r'(<li[^>]*>)\s*<p>(.*?)</p>', r'\1\2', html, flags=re.DOTALL)

    css_style = """<style>
      ul, ol {
        margin-top: 0.25em !important;
        margin-bottom: 0.35em !important;
        padding-left: 1.6em !important;
      }
      li {
        margin-top: 0 !important;
        margin-bottom: 0.15em !important;
        padding: 0 !important;
        line-height: 1.4 !important;
      }
      li > p {
        margin: 0 !important;
        padding: 0 !important;
        display: inline !important;
      }
      li > ul, li > ol {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        padding-left: 1.4em !important;
      }
      blockquote {
        margin: 0.6em 0 !important;
        padding: 0.2em 0.8em !important;
        border-left: 3px solid #0066cc !important;
        background-color: #f7f9fa !important;
        color: #444 !important;
      }
      blockquote p {
        margin: 0 !important;
      }
      /* Style for clean math rendering */
      .math-display {
        text-align: center !important;
        margin: 1em 0 !important;
        font-size: 1.05em !important;
      }
      .math-inline {
        font-style: normal !important;
      }
    </style>
</head>"""

    if '</head>' in html:
        html = html.replace('</head>', css_style, 1)

    return html

def main():
    if len(sys.argv) < 3:
        print('Usage: python3 py.py input.md output.html')
        sys.exit(1)

    input_file = sys.argv[1]
    output_file = sys.argv[2]

    if not os.path.exists(input_file):
        print(f"Error: File '{input_file}' does not exist.")
        sys.exit(1)

    with open(input_file, 'r', encoding='utf-8') as f:
        original_md = f.read()

    # 1. Preprocessing (LaTeX -> HTML, fixing list structure and blockquotes)
    modified_md = fix_and_prepare_markdown(original_md)

    # 2. Conversion via Pandoc
    command = [
        'pandoc',
        '-f', 'markdown',
        '-t', 'html',
        '-s'
    ]

    process = subprocess.run(command, input=modified_md, capture_output=True, text=True)

    if process.returncode != 0:
        print('Error during Pandoc conversion:')
        print(process.stderr)
        sys.exit(1)

    # 3. Change subheadings h3 through h6 into regular paragraphs with bold text
    html_without_h3 = replace_subheadings_with_bold(process.stdout)

    # 4. Final space cleaning in HTML and CSS application
    final_html = clean_spaces_in_html(html_without_h3)

    with open(output_file, 'w', encoding='utf-8') as f:
        f.write(final_html)

    print(f'Successfully converted to: {output_file}')

if __name__ == '__main__':
    main()

Other example of incorrect markdown from Google AI studio and issue with convert

$$\approx 14\text{ MB (1. pokus)} + 14\text{ MB (2. pokus)} + 14\text{ MB (3. pokus)} + \text{TCP réžia} \approx \mathbf{44{,}5\text{ MB}}$$

Snímka obrazovky_20260929_125117

Snímka obrazovky_20260929_125338

Snímka obrazovky_20260929_125305

Exactly the same problems going on for 3rd week now for me.
At times, it gets so bad that even plaintext has problems appearing.

It’s practically unusable now.

Yes, it’s really bad!