tdewolff / minify

Go minifiers for web formats

Home Page:https://go.tacodewolff.nl/minify

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`--html-keep-quotes`, mixed single and double quotes in final output

dehghani-mehdi opened this issue · comments

<!doctype html>
<html lang='en'>
    <head>
        <meta charset='utf-8'>
        <meta name='viewport' content='width=device-width, initial-scale=1'>
        <title>Bootstrap demo</title>
        <link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css' rel='stylesheet' crossorigin='anonymous'>
    </head>
    <body>
        <h1>Hello, world!</h1>
        <script src='https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js' crossorigin='anonymous'></script>
    </body>
</html>

Running minify --type=html --html-keep-quotes --html-keep-end-tags --html-keep-document-tags will produce this:

<!doctype html><html lang='en'><head><meta charset='utf-8'><meta name='viewport' content="width=device-width,initial-scale=1"><title>Bootstrap demo</title>
<link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css' rel='stylesheet' crossorigin='anonymous'></head><body><h1>Hello, world!</h1><script src='https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js' crossorigin='anonymous'></script></body></html>

As you can see there are some double quotes in the final output content="width=device-width,initial-scale=1", I couldn't find any option to tell minify to use only single quote (or double quote)

Using either single or double quotes doesn't matter in HTML, so you shouldn't have any problems with this. What use-case do you have?

Currently, --html-keep-quotes means it will not strip away quotes but it will still optimize the content and use either single or double quotes, whichever is shorter. I can understand that it could also mean: keep the original quotes, in which case it should not change to single/double quotes and omit optimizing the attribute value w.r.t. quote usage. But again, why is this causing problems for you?

It broke all my unit tests, I could replace all double quotes with single ones before running my tests, but I think you should consider fixing this.