Skip to content

Add missing space between style and class attributes on line elements#6

Open
dereuromark wants to merge 1 commit into
torchlight-api:mainfrom
dereuromark:fix-line-style-class-attribute-space
Open

Add missing space between style and class attributes on line elements#6
dereuromark wants to merge 1 commit into
torchlight-api:mainfrom
dereuromark:fix-line-style-class-attribute-space

Conversation

@dereuromark

Copy link
Copy Markdown

Problem

Lines that carry a line style (highlight, diff add/remove, focus) render with the class attribute glued onto the quoted style value - no separating space:

<div style="background: #2b3036"class='line line-highlight line-has-background'>

HtmlGenerator::buildLineElement() only appends a space after the attribute string, not after the style attribute.

Browsers recover from this, so it is easy to miss. Strict HTML sanitizers do not: WordPress' wp_kses, for example, drops the whole mangled attribute run, so highlighted/diff lines lose their line line-highlight / line-add / line-remove classes after sanitization - which breaks line padding, gutter alignment, and any styling keyed to those classes.

Fix

Emit a trailing space after the style attribute. The 19 acceptance fixtures that asserted the glued markup verbatim are updated, and a regression test asserts no "class= / 'class= junction remains in generated output.

Full suite: 514 passed (PHP 8.3).

Lines that carry a line style (highlight, diff, focus) rendered as
style="..."class='line ...' with no separator. Browsers recover, but
HTML sanitizers reject the mangled attribute run - WordPress' wp_kses
strips the class list from such lines entirely, breaking gutter padding
and accent styling downstream. Acceptance fixtures updated accordingly.
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.

1 participant