Classify HTML bogus comments as comment tokens
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 66/100
Rechercherichtung
Start in HTMLParser.parseHtml, at the branch that handles < ! ... > and currently only recognises [ marked sections and -- comments; everything else falls through to declaration token D. Read how the C token is emitted for <!-- --> and mirror that path for the bogus-comment form, then confirm via HTML::TokeParser that <! comment !> yields ['C', ...]. Reproduce first with the ignore_comments snippet, then add token-classification and diff regression tests and run t/text_diff.t on both the JVM and interpreter backends.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
The HTML::Parser implementation classifies the HTML bogus comment <! comment !> as a declaration. System Perl classifies the same token as a comment. This causes callers that ignore comments to retain the token and report a false HTML difference.
Reproduction
With HTML-Differences 0.01:
use HTML::Differences qw(html_text_diff);
my $left = '<p>x</p>';
my $right = '<p>x</p><! comment !>';
print html_text_diff($left, $right, ignore_comments => 1);
Expected: an empty string, because the only difference is a comment and ignore_comments is enabled.
Actual on PerlOnJava: the diff includes <! comment !> as an added line.
A direct token check isolates the discrepancy: HTML::TokeParser under system Perl emits ['C', '<! comment !>']; PerlOnJava emits ['D', '<! comment !>']. HTML::Differences::diffable_html dispatches C tokens to its comment handler, which drops them when ignore_comments is true. A D token goes to the declaration handler and is kept, so the option is bypassed.
Evidence
- CPAN distribution: HTML-Differences 0.01; tester run
20261120-195805-13340. - Upstream system-Perl oracle: all 14 tests passed, including
t/text_diff.t. - PerlOnJava:
t/text_diff.tfails itsno diff found when comment differs and told to ignore commentsassertion. - The same failure reproduces on JVM and interpreter backends.
- Runtime reports Perl 5.44.1, Java 24.0.2, macOS (Darwin 25.6). The tester's system-Perl oracle used Perl 5.42.2.
- The module is pure Perl; no native dependency or external service is involved.
Root cause
In HTMLParser.parseHtml, the branch handling <!...> recognizes marked sections beginning with [ and comments beginning with --. Every other form is emitted as a declaration. It does not implement HTML::Parser's bogus-comment handling for <! ... >, which is why <! comment !> receives token type D rather than C.
Acceptance criteria
<! comment !>is emitted as a comment token by HTML::TokeParser, matching system Perl.- The minimal
ignore_commentsreproducer returns an empty string on JVM and interpreter backends. - Add focused project-owned regression coverage for token classification and ignored-comment diffing, validated against system Perl.
- Re-run HTML-Differences 0.01
t/text_diff.ton both PerlOnJava backends.
- Vorherrschende Sprache
- Perl
- Sterne
- 67
- Forks
- 8
- Ø Merge
- 5 Std. 12 Min.
- Gemergte PRs (30 T.)
- 131
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus fglock/PerlOnJava
-
area:cpan-port bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
fglock/PerlOnJava#2153 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area:cpan-port area:parser bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
fglock/PerlOnJava#2137 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area:backend area:cpan-port area:runtime bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
fglock/PerlOnJava#2071 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area:runtime documentation enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
fglock/PerlOnJava#1579 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area:cpan-port bug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 62/100
fglock/PerlOnJava#2157 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in fglock/PerlOnJava
Ähnliche Issues
-
Dev-output directory preparation accepts file-valued lib/include paths and fails on dangling linksOffenteam-cli
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 93/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 73/100
inverse-inc/packetfence#9728 ·
Maintainer antworten meist innerhalb von 1 Tag
-
fix(char-create): show the real reason a character is refusedEvtl. vergeben @baphomello hat das vor 1 Tag übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 1 Tag