openpdf-html: use ph-css CSS parser#1561
Open
andreasrosdalw wants to merge 4 commits into
Open
Conversation
Add com.helger:ph-css 8.2.0 as a dependency and lay the groundwork
for replacing the hand-written JFlex CSS 2.1 parser with a modern
CSS3/4-capable engine.
New package org.openpdf.css.phcss:
- PhCssStylesheetFactory: static parse(String/Reader/InputStream)
entry points backed by ph-css CSSReader.
- PhCssParser: instance wrapper mirroring the legacy CSSParser surface
to ease the migration for callers.
- PhCssToOpenPdfAdapter: maps a ph-css CascadingStyleSheet onto the
openpdf-html Stylesheet/Ruleset/PropertyDeclaration model, handling
style rules, @media, @font-face, @page, and @import. Selector and
value parsing delegates to the legacy CSSParser during the transition.
Covered by 15 unit tests.
Legacy org.openpdf.css.parser, org.openpdf.css.parser.property, and
CSSName marked @deprecated(since = "3.0.5"). The legacy parser remains
the default; nothing is removed yet.
Also fixes misplaced Javadoc (annotations before /** block in CSSParser
and Token), a duplicate /** block in BuilderUtil, dead code in the
initial PhCssToOpenPdfAdapter stub, and a repeated LoggingCSSParseErrorHandler
construction now replaced by a shared constant.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 61 |
| Duplication | 2 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
- Remove unused CSSSelector import from PhCssToOpenPdfAdapter - Import PropertyDeclaration instead of using fully-qualified type name - Extract duplicate string literal to STRING_READER_IO_MSG constant - Rename unused uri parameters to ignoredUri in PhCssParser Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



#1558
Add com.helger:ph-css 8.2.0 as a dependency and lay the groundwork for replacing the hand-written JFlex CSS 2.1 parser with a modern CSS3/4-capable engine.
https://github.com/phax/ph-css
New package org.openpdf.css.phcss:
Legacy org.openpdf.css.parser, org.openpdf.css.parser.property, and CSSName marked @deprecated(since = "3.0.5"). The legacy parser remains the default; nothing is removed yet.
Also fixes misplaced Javadoc (annotations before /** block in CSSParser and Token), a duplicate /** block in BuilderUtil, dead code in the initial PhCssToOpenPdfAdapter stub, and a repeated LoggingCSSParseErrorHandler construction now replaced by a shared constant.
Note that this is a "research" and innovation time project where I have spent time trying to improve OpenPDF using AI tools such as Claude and Copilot.
Your real name
Andreas Røsdal