> I have some questions:
1. Is the "SingleFileZ" web extension necessary? I opened a xxx.zip.html in Opera, it shows the same message. (NOTE: the Obsidian is based on [Electron](https://www.electronjs.org/), which embedded a Chromium browser)
It is unfortunately necessary to install SingleFileZ to view pages from the filesystem in Chromium-based browsers because they don't allow to run fetch("")
(in order to retrieve the displayed page in binary) when the page is opened from the filesystem. It looks like the same limitation is applied in Obsidian.
2. How to detect a .html file made by "SingleFileZ"?
The file can be unzipped and it contains an index.html
file in the root folder or the first folder of the zip file (for MAFF files). In addition, for self-extracting pages, the <html>
tag contains the attribute data-sfz
.
3. Is there a npm package to convert/decode SingleFileZ's .html content to standard HTML string?
The function extractPage
in the code below (heavily inspired from this gist) should help you.
import { extract } from "https://raw.githubusercontent.com/gildas-lormeau/SingleFileZ/master/src/single-file/processors/compression/compression-extract.js";
import * as zip from "https://raw.githubusercontent.com/gildas-lormeau/zip.js/master/index.js";
globalThis.zip = zip;
async function extractPage(zipBlob) {
const { docContent } = await extract(zipBlob, { noBlobURL: true });
return docContent;
}
You can also use local imports instead of retrieving scripts from raw.githubusercontent.com
by importing single-filez-core
and zip.js
from NPM, and replacing "https://raw.githubusercontent.com/gildas-lormeau/SingleFileZ/master/src/single-file"
with "single-filez-core"
and "https://raw.githubusercontent.com/gildas-lormeau/zip.js/master/index.js"
with "@zip.js/zip.js"
.
Originally posted by @gildas-lormeau in https://github.com/nuthrash/obsidian-html-plugin/issues/1#issuecomment-1284760013
help wanted