Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Addition < at first line #41

Open
sotatek-truongpham opened this issue Apr 27, 2022 · 1 comment
Open

Bug: Addition < at first line #41

sotatek-truongpham opened this issue Apr 27, 2022 · 1 comment

Comments

@sotatek-truongpham
Copy link

sotatek-truongpham commented Apr 27, 2022

With text ■Campaign Overview update:

result: <■Campaign Overview update:

@sotatek-truongpham sotatek-truongpham changed the title Addition < at first line Bug: Addition < at first line Apr 27, 2022
@davidcmoody
Copy link

So, after investigating, this happens when the $html we supply doesn't start with an element. To combat this, I have changed the html function in TinyMinify to this:

  public static function html(string $html, array $options = []) : string
   {
       $minifier = new TinyHtmlMinifier($options);
       $result = $minifier->minify($html);
       
       $min_char1 = substr($result,0,1);
       if ($min_char1 == substr($html,0,1)) {
           return $result;
       } else {
           if ($min_char1 == '<') {
   	        return substr($result, 1);
           }
       }
   }

Probably not the best way to combat it, but it works for my use case.

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

No branches or pull requests

2 participants