byrnereese/mkdocs-minify-plugin

[feature request] Possibility to provide htmlmin options

Closed this issue · 11 comments

Hi! Thx a lot for your plugin :)

Still, i was wondering if you could add the possibility to pass htmlmin options? For instance, I'd be happy to remove internal comments when I build my documentation, but there's no way to pass the options remove_comments=False from htmlmin.

As for reference: https://htmlmin.readthedocs.io/en/latest/reference.html

Thanks in advance for your answer!

ofek commented

@byrnereese Hello! Any progress on this?

Hope that @byrnereese will get in touch soon. In the meantime, you could use StripHTML for some basic tasks including removing comments.

I have implemented this feature in 0.2.2 which I just deployed to pypi. See the updated README for the syntax. Please test and let me know if this works as you expect.

ofek commented

Awesome, thanks!

v0.2.2 doesn't work:

 File "c:\program files (x86)\python37-32\lib\site-packages\mkdocs_minify_plugin\plugin.py", line 33
    print "htmlmin option " + key + " not recognized"
                          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("htmlmin option " + key + " not recognized")?
ofek commented

Oof yes, we also use Python 3

My apologies for that oversight. I forgot to remove my debug lines. I have shipped 0.2.3 with parens added, and some print statements removed. Please let me know if this now works.

ofek commented

It works 👍

Actually, it doesn't work. It only works for remove_comments, not for any other options. That's because you pass the options as a dict object, but minify() expects each option as a separate parameter in a specific order.

I created a PR that fixes this: #9

@byrnereese Thanks for merging. Could you also upload 0.3.0 to PyPI? Thanks 🤝