bitlooter / htmlark Goto Github PK
View Code? Open in Web Editor NEWPack a webpage including images and CSS into a single HTML file
License: MIT License
Pack a webpage including images and CSS into a single HTML file
License: MIT License
right now htmlark adds useful comments about which original file was used before the data-uri.
this is sometimes unecessary (e.g. in production), and maybe even be the default, while the comments can be added with (for example) a --debug option.
thanks
I've tried to run htmlark on a few reveal.js based presentations (https://github.com/hakimel/reveal.js/).
I found that while in principle it is possible to get results, a lot of features are unsupported and there are many fail cases:
Any chance of updating this application adding support for reveal.js? (seems like could be a lot of effort; maybe can collaborate on this.) Anyway, I would like to learn of your thoughts on this. Thanks!
On the page https://www.bbc.co.uk/news/world-africa-51063149
I ran a test and the logo "NEWS" at the top left of the page is not turned into a data url although the picture on the page is.
I did the following:
import htmlark
packed_html = htmlark.convert_page('https://www.bbc.co.uk/news/world-africa-51063149', ignore_errors=True)
f = open('htmlark_test.html', 'w')
f.write(packed_html)
f.close()
I looked at the documentation and its not totally clear how I can try different parsers like html5lib etc, is it that I'm not using the correct parser here or something else?
Given an HTML file containing a css resource using an aboslute path:
<link rel=stylesheet href=/css/site.css>
Result:
$ htmlark mypage.html
**SS: Error reading '/css/site.css': No such file or directory
Unable to convert webpage: [Errno 2] No such file or directory: '/css/site.css'**
I think htmlark should be able to handle this better.
When a browser sees a reference like:
src="folder%20name\file.jpg"
it will look for:
src="folder name\file.jpg"
Some browsers even save embedded urls this way.
This behavior should be considered in htmlark, while searching for external files.
thanks!
Just like the title says. I found that my empty src attribute received a very long base64 string, so I decoded it, and it contains my index.html.
So I tried the recommended approach for empty src's, src='//:0' and got "No such file or directory: '//:0'". (See https://stackoverflow.com/questions/19126185/setting-an-image-src-to-empty/19126281).
Note that src='#' isn't recommended.
So I tried a 1 pixel image, which worked: src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
Add the ability to embed linked iframes into pages. Will need to research browser compatibility.
Add the option to ignore or strip out resources from certain domains, or allow only specified domains. Also should allow the option to ignore all third-party domains during processing. This can be useful for not embedding advertisements or ad tracking scripts into packed files.
convert_page fails on windows when called with paths containing drive letter as page_path because it treats the drive letter of a windows path as an url scheme.
Env:
Python 3.7.2
Windows 10
Repro:
import htmlark
htmlark.convert_page('C:\\page.html')
=>
Traceback (most recent call last):
File "Python37\lib\site-packages\htmlark.py", line 177, in convert_page
_, page_text = _get_resource(page_path)
File "Python37\lib\site-packages\htmlark.py", line 77, in _get_resource
raise ValueError("Not local path or HTTP/HTTPS URL", url_parsed.scheme)
ValueError: ('Not local path or HTTP/HTTPS URL', 'c')
HTMLArk should have a reverse function, extracting embedded resources back into files.
Linked url() resources in CSS should be embedded as well. This applies to linked CSS files and embedded CSS.
right now CSS is treated as a binry file, and the embedded code is binhex / data-uri.
bin-hex doesn't conserve space, and cannot be debugged / edited / enhanced.
Please embed CSS as is, between <style> tags, and not serialized.
Thanks!
Make use of Python's logging module for better integration with programs that import it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.