Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 31, 2025

Fixes #1504

This PR implements support for CSS string literals as list-style-type values, allowing developers to use custom text markers for HTML lists.

What's Changed

Previously, the list-style-type property only supported predefined CSS keywords like disc, circle, decimal, etc. This implementation adds support for quoted string literals as specified in the CSS specification.

Examples

<!-- Custom numbered markers -->
<ul style="list-style-type: '① '">
  <li>First item</li>
  <li>Second item</li>
</ul>

<!-- Custom text markers -->
<ol style="list-style-type: 'Step '">
  <li>Initialize</li>
  <li>Process</li>
</ol>

<!-- Empty string (no marker) -->
<ul style="list-style-type: ''">
  <li>Item without marker</li>
</ul>

Implementation Details

  • String Detection: Modified getListMarkerText() to treat any unrecognized list-style-type value as a string literal
  • Quote Handling: The CSS parser already handles quote extraction and HTML entity decoding (&quot;")
  • Empty Strings: Empty string literals properly render without markers (like list-style-type: none)
  • Compatibility: All existing functionality preserved - geometric markers (disc, circle, square) and serial markers (decimal, roman, alpha) work unchanged

Technical Changes

  • Updated getListMarkerText() in core_widget_factory.dart to return unrecognized types as-is
  • Modified buildListMarker() to handle empty string literals by returning null (no marker)
  • Added _isPredefinedListStyleType() helper to distinguish between CSS keywords and string literals
  • Enhanced test coverage with comprehensive string literal test cases

Test Results

  • ✅ All existing tests pass (70/70 core package tests)
  • ✅ All integration tests pass (46/46 enhanced package tests)
  • ✅ Full test suite passes (233/233 total tests)
  • ✅ End-to-end verification confirms custom markers render correctly

This change maintains full backward compatibility while enabling the flexible list styling requested in the original issue.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Implement this feature request @daohoangson/flutter_widget_from_html/issues/1504 Add support for string literals in CSS list-style-type property Aug 31, 2025
Copilot AI requested a review from daohoangson August 31, 2025 15:10
Copilot finished work on behalf of daohoangson August 31, 2025 15:10
@sonarqubecloud
Copy link

@github-actions
Copy link

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.

[Feature Request] Support for string literals as list-style-type

2 participants