Skip to content

Improve HTML to markdown processor with Mozilla Readability integration#359

Draft
CNSeniorious000 with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-42a33afc-e671-448a-8b41-cd845031a477
Draft

Improve HTML to markdown processor with Mozilla Readability integration#359
CNSeniorious000 with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-42a33afc-e671-448a-8b41-cd845031a477

Conversation

Copilot AI commented Aug 4, 2025

Copy link
Copy Markdown
Contributor

Implements issue #79 by integrating Mozilla Readability into the HTML to markdown conversion pipeline to extract main content and filter out boilerplate elements like navigation, ads, and sidebars.

Changes Made

Enhanced src/lib/utils/html.ts:

  • Added extractMainContent() function that uses Mozilla Readability to clean HTML before conversion
  • Integrated Readability processing into the existing html2markdown() function
  • Maintains full backward compatibility with graceful fallback to original HTML if Readability fails
  • Preserves the existing unified processor + TurndownService conversion pipeline

Dependencies Added:

  • @mozilla/readability - Mozilla's content extraction library
  • jsdom - DOM environment for server-side Readability processing
  • @types/jsdom and @types/domhandler for TypeScript support

Benefits

The improved processor now provides cleaner markdown output by:

  • Extracting main article content from complex web pages
  • Filtering out navigation menus, advertisements, and footer content
  • Preserving essential content like headings, paragraphs, code blocks, and lists
  • Maintaining existing functionality for simple HTML content

Testing

Validated on PyPI project pages (e.g., /pypi/requests) showing significant improvement in markdown quality:

  • Main content properly extracted and formatted
  • Boilerplate content successfully filtered out
  • Code examples and installation instructions cleanly preserved
  • All builds and linting pass successfully

This enhancement is particularly beneficial for the PyPI project description conversion feature, resulting in much cleaner and more focused markdown output.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@codesandbox

codesandbox Bot commented Aug 4, 2025

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

…wn processing

Co-authored-by: CNSeniorious000 <74518716+CNSeniorious000@users.noreply.github.com>
Copilot AI changed the title [WIP] 实现 #79 Improve HTML to markdown processor with Mozilla Readability integration Aug 4, 2025
Copilot AI requested a review from CNSeniorious000 August 4, 2025 03:23
@CNSeniorious000
CNSeniorious000 force-pushed the main branch 2 times, most recently from f843396 to 3c3b858 Compare August 18, 2025 16:25
@CNSeniorious000
CNSeniorious000 force-pushed the main branch 6 times, most recently from 31563be to 2590220 Compare September 9, 2025 04:07
@CNSeniorious000
CNSeniorious000 force-pushed the main branch 5 times, most recently from 0dafc1f to 4cbbea5 Compare November 4, 2025 07:11
@CNSeniorious000
CNSeniorious000 force-pushed the main branch 2 times, most recently from e085e54 to 4400899 Compare December 5, 2025 04:21
@CNSeniorious000
CNSeniorious000 force-pushed the main branch 2 times, most recently from b43321b to e2a8f1b Compare March 12, 2026 18:15
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.

2 participants