Skip to content

Conversation

@dfop02
Copy link
Owner

@dfop02 dfop02 commented Dec 27, 2025

Description

Add External CSS Support

Adds support for <style> tags and loading CSS from external files via <link rel="stylesheet"> tags.

Features

  • Local and remote CSS files: Supports both local file paths and HTTP/HTTPS URLs
  • Selective parsing: Only loads CSS rules relevant to HTML elements, improving performance with large CSS frameworks
  • Multiple CSS files: Can load multiple external stylesheets
  • Combined with inline styles: Works alongside <style> tags and inline styles
  • Error handling: Gracefully handles missing or invalid CSS files without breaking HTML conversion

Usage

<link rel="stylesheet" href="https://example.com/style.css">
<link rel="stylesheet" href="./local/styles.css">

External CSS rules follow the same precedence as <style> tag rules and are applied according to standard CSS specificity.

Implementation

  • Added fetch_external_css() utility function for loading CSS from URLs and local files
  • Extended HTML parser to detect and process <link> tags
  • Integrated with existing CSS parser using selective parsing mode
  • <link> tags are automatically removed from the output document

Issue Reference

None

Checklist Before Requesting a Review

  • I have performed a self-review of my code.
  • My code follows the project's coding style and guidelines.
  • I have run tests and verified that all existing and new tests pass.
  • I have added new tests to cover my changes.

@dfop02 dfop02 self-assigned this Dec 27, 2025
@dfop02 dfop02 added documentation Improvements or additions to documentation New Feature New feature or request labels Dec 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation New Feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants