[英]How to convert HMTL file with content folder to a self-contained HTML file
How do I convert an HTML file with content folder to a self-contained HTML file which can be viewed from anywhere with its images etc. 如何将带有内容文件夹的HTML文件转换为自包含的HTML文件,可以从任何地方查看其文件等。
How can it be done so that its also Editable and stays self-contained post-edit. 如何才能使其也可以编辑并保持自包含的后期编辑。
I basically need to make HTML file based documentation which can be viewed from anywhere. 我基本上需要制作基于HTML文件的文档,可以从任何地方查看。 Unfortunately it HAS to be HTML, otherwise I would have made PDFs
不幸的是它是HTML,否则我会制作PDF
Thanks 谢谢
The most direct way is to convert all asset urls to data:
urls . 最直接的方法是将所有资产网址转换为
data:
网址 。 (There are online coverters available that will take a provided asset and produce a data:
url from it.) (有可用的在线变换器将获取提供的资产并生成
data:
来自它的URL。)
A possibly simpler way is to convert image and font urls to data:
urls while instead inlining scripts and css. 一种可能更简单的方法是将图像和字体URL转换为
data:
urls而不是内联脚本和css。
Edit: Possibly of interest: inliner , a Node utility for doing this kind of thing. 编辑:可能有兴趣: inliner ,一个用于做这种事情的Node实用程序。 "Turns your web page to a single HTML file with everything inlined".
“将您的网页变为单个HTML文件,内嵌所有内容”。 Also performs a number of minifying optimizations.
还执行许多缩小优化。
I don't know exactly what you're envisioning, but HTML was never meant to be fully self-contained. 我不确切地知道你想象的是什么,但HTML从来就不是完全独立的。 There may be some loopholes that allow it in the end, but to my knowledge there are no premade tools that do this 'conversion'.
可能有一些漏洞最终允许它,但据我所知,没有预制工具可以实现这种“转换”。 It would require the following things:
这需要以下几点:
<script src="http://url.to/foo.js"></script>
you'll have to download foo.js and include it as such: <script type="text/javascript"> [this is the content of foo.js] </script>
. <script src="http://url.to/foo.js"></script>
您就必须下载foo.js并将其包含在内: <script type="text/javascript"> [this is the content of foo.js] </script>
。 Something similar applies to CSS and other linked source files. <img src="http://url.to/image.jpg" />
with <img src="data:image/png;base64,[converted image data goes here] />
. So there's gonna be some manual labour involved there, but it probably can be done (almost) fully. <img src="http://url.to/image.jpg" />
<img src="data:image/png;base64,[converted image data goes here] />
替换<img src="http://url.to/image.jpg" />
<img src="data:image/png;base64,[converted image data goes here] />
。所以会有那里涉及一些体力劳动,但它可能(几乎)完全完成。 Possibly there's a way to accomplish what you're wanting to do another way though, what exactly is your reason for wanting this? 可能有一种方法可以完成你想要做的另一种方式,你究竟想要这个的原因是什么?
Here's another option: write your documentation in markup, then use a tool such as "Marked 2" ( http://marked2app.com ) to convert to self-contained html. 这是另一种选择:在标记中编写文档,然后使用诸如“Marked 2”( http://marked2app.com )之类的工具转换为自包含的 html。 Works slick.
工作光滑。 Plus you can go back and edit the markup any time you need to update your documentation, then simply re-export your html file.
此外,您可以在需要更新文档时返回并编辑标记,然后只需重新导出html文件即可。
You can use pandoc
, it has an option to create self-contained html files https://pandoc.org/MANUAL.html#option--self-contained . 您可以使用
pandoc
,它可以选择创建自包含的html文件https://pandoc.org/MANUAL.html#option--self-contained 。
If you start with html
, this is the command. 如果你从
html
开始,这就是命令。
pandoc in.html --self-contained -o out.html
This tool can do a lot more things, for example, you can also generate html
from markdown files or generate pdf
s instead. 这个工具可以做更多的事情的东西,例如,您还可以生成
html
的降价文件或生成pdf
!而非。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.