Skip to content

fix(filesystem): render markdown emphasis in PDF export - #5540

Merged
MagMueller merged 3 commits into
browser-use:mainfrom
leilei3167:fix/pdf-markdown-formatting
Aug 27, 2026
Merged

MagMueller merged 3 commits into
browser-use:mainfrom
leilei3167:fix/pdf-markdown-formatting

Conversation

@leilei3167

@leilei3167 leilei3167 commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

write_file tells the model that PDF content is markdown, but after #5502 only # / ## / ### headings were styled. Bold, italic, inline code, and bullets printed as literal **syntax**.

Keep the #5502 escape-first behavior (raw ReportLab markup cannot be restored — that is the parse bug). After html.escape, convert a small markdown subset to RML. Underscores stay literal so snake_case names are not italicized. * is only emphasis when it actually wraps a span — 2 * 3 * 4 and globs are left alone. Fenced blocks skip inline conversion so shell backticks survive.

Heading offsets are shared with DocxFile via _split_heading.

Fixes #5538


Summary by cubic

Render markdown emphasis in PDF exports from write_file so PDFs match the documented markdown contract. Previously only #/##/### headings rendered; now bold, italic, inline code, and bullets format correctly while we keep the escape-first fix to avoid ReportLab parse issues.

  • Convert **bold**, *italic*, `inline`, and list bullets (-/*) to RML; code fences bypass inline conversion; underscores never italicize.
  • Keep glob tokens and arithmetic stars literal (e.g., *.txt, **/foo/**, 2 * 3 * 4); inline code protects emphasis markers.
  • Restore inline code via collision-safe placeholders so user text cannot be mistaken for stash tokens.
  • Share heading parsing with DocxFile to align #/##/### levels; add tests for emphasis, bullets, fences, globs, and edge cases.

Written for commit f168606. Summary will update on new commits.

Review in cubic

@CLAassistant

CLAassistant commented Aug 25, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread browser_use/filesystem/file_system.py Resolved
Comment thread browser_use/filesystem/file_system.py Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread browser_use/filesystem/file_system.py Resolved
@MagMueller
MagMueller force-pushed the fix/pdf-markdown-formatting branch from 6cee364 to a8f48ff Compare August 27, 2026 07:34
leilei3167 and others added 3 commits August 27, 2026 16:27
Escape first to keep the ReportLab parse fix, then convert bold/italic/code/bullets to RML so write_file PDFs match the documented markdown contract.
@MagMueller
MagMueller force-pushed the fix/pdf-markdown-formatting branch from a8f48ff to f168606 Compare August 27, 2026 23:28
@MagMueller
MagMueller merged commit 6ed72e1 into browser-use:main Aug 27, 2026
109 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PDF export renders markdown as literal syntax (only headers are handled)

3 participants