Skip to content

Add HTML support (with options!)#41

Open
Kocal wants to merge 3 commits into
sensiolabs:mainfrom
bakslashHQ:feat/html-support
Open

Add HTML support (with options!)#41
Kocal wants to merge 3 commits into
sensiolabs:mainfrom
bakslashHQ:feat/html-support

Conversation

@Kocal

@Kocal Kocal commented May 20, 2026

Copy link
Copy Markdown

We use this bundle on baksla.sh to programmatically minify HTML files (SSG), but today we ran into an issue where the site preview on LinkedIn wasn't working: our og:image tag was being ignored.

It turns out that LinkedIn's parser (https://www.linkedin.com/post-inspector/) doesn't work correctly when the <head> and </head> tags are missing... 😫

This PR adds support for HTML and options (just one option for now, KISS), but only in the low-level MinifyInterface::minify() method.
I deliberately did not touch the bundle (i.e., adding configuration to SensiolabsMinifyBundle and modifying the MinifierCompiler, etc..), because I don't think it makes sense with the AssetMapper's integration (JS/CSS only).

Comment thread .gitignore
Comment thread CHANGELOG.md
Kocal added a commit to bakslashHQ/baksla.sh that referenced this pull request May 20, 2026
…improvements

Related to our LinkedIn post preview issue... The `og:image` can't be displayed because of missing `<head>` tags.

Opened sensiolabs/minify-bundle#41.
Kocal added a commit to bakslashHQ/baksla.sh that referenced this pull request May 20, 2026
…improvements

Related to our LinkedIn post preview issue... The `og:image` can't be displayed because of missing `<head>` tags.

Opened sensiolabs/minify-bundle#41.
mtarld pushed a commit to bakslashHQ/baksla.sh that referenced this pull request May 21, 2026
…improvements (#149)

Related to our LinkedIn post preview issue... The `og:image` can't be displayed because of missing `<head>` tags.

Opened sensiolabs/minify-bundle#41.
@smnandre

Copy link
Copy Markdown
Member

omg this is open for so long oO

Comment thread src/Minifier/Options/OptionsInterface.php
Comment thread src/Minifier/TraceableMinifier.php Outdated
Comment thread src/Minify.php
}

public function minify(string $input, string $type): string
public function minify(string $input, string $type/* , ?OptionsInterface $options = null */): string

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment / deprecartion here, this feels so legit i'd agree to release a 2.0 there if we generalise this

Comment thread CHANGELOG.md Outdated

@smnandre smnandre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments here and there. Please add your author name in classes you introduce ;)

and... sorry for the (omg) time to see this.

I never got any notification here... but I should have seen it 🫢

@smnandre

Copy link
Copy Markdown
Member

(and obviously thank you for your PR ❤️ )

@smnandre

Copy link
Copy Markdown
Member

@Kocal (would not want you to receive notification during winter 😅 )

@Kocal

Kocal commented Jun 30, 2026

Copy link
Copy Markdown
Author

No worries, we've all been there :)

I just pushed some modifications based on your comments

@smnandre

Copy link
Copy Markdown
Member

Minor cs/sa fix and LGTML :)

And then we'll be able to prepare 2.0 (i wanted to add other formats too, and maybe some proactive minification)

Thx @Kocal

@Kocal Kocal force-pushed the feat/html-support branch from 0d86ab0 to 86ebce8 Compare June 30, 2026 20:52
@Kocal Kocal force-pushed the feat/html-support branch from 3be3529 to b6a7ea4 Compare June 30, 2026 20:56
@Kocal

Kocal commented Jun 30, 2026

Copy link
Copy Markdown
Author

Fixed.

About PHPStan, I added the following errors in its baseline. It looks like PHPStan does not like the way to add a new method parameter on an interface without breaking the BC layer.

Note: Using configuration file /home/runner/work/minify-bundle/minify-bundle/phpstan.dist.neon.
  0/20 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░]   0%
 20/20 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

Error: PHPDoc tag `@param` references unknown parameter: $options
Error: Method Sensiolabs\MinifyBundle\Minifier\MinifierInterface::minify() invoked with 3 parameters, 2 required.
 ------ ---------------------------------------------------------- 
  Line   Minifier/MinifierInterface.php                            
 ------ ---------------------------------------------------------- 
  31     PHPDoc tag @param references unknown parameter: $options  
         🪪  parameter.notFound                                    
 ------ ---------------------------------------------------------- 

 ------ --------------------------------------------------------------------- 
  Line   Minifier/TraceableMinifier.php                                       
 ------ --------------------------------------------------------------------- 
  41     Method Sensiolabs\MinifyBundle\Minifier\MinifierInterface::minify()  
         invoked with 3 parameters, 2 required.                               
         🪪  arguments.count                                                  
 ------ --------------------------------------------------------------------- 

Note: the CI run PHPStan only on src/ folder and completely ignore paths defined in phpstan.dist.neon config file. More errors can be found from tests/ folder.

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.

2 participants