@sheeptester/htmlifier

1.0.3 • Public • Published

HTMLifier for Node

Package a Scratch project inside an HTML file with no optimisations.

Installation

$ npm install @sheeptester/htmlifier

Example usage

The following example HTMLifies Scratch 3.0 is here! and writes the result to a file named index.html.

import fs from 'fs/promises'
import Htmlifier from '@sheeptester/htmlifier'

async function main () {
  const html = await new Htmlifier()
    .htmlify({ type: 'id', id: '276660763' })
    .then(blob => blob.text())
  await fs.writeFile('./index.html', html)
}

main()

Because node-fetch is strictly an ES module, this package is also an ES module. If you're using a CommonJS module, you can use esm to import this package.

require = require('esm')(module)
const Htmlifier = require('@sheeptester/htmlifier')

The HTMLifier was primarily written for Deno and the web, so it uses Blobs and Files to pass binary data around. You can use fetch-blob to create Blobs and Files for the HTMLifier.

import Htmlifier from '@sheeptester/htmlifier'
import { fileFrom } from 'fetch-blob/from.js'

async function main () {
  const html = await new Htmlifier()
    .htmlify({ type: 'file', file: await fileFrom('./project.sb3') })
    .then(blob => blob.text())
  // ...
}

main()

Documentation

Auto-generated documentation is available courtesy of deno doc.

Readme

Keywords

Package Sidebar

Install

npm i @sheeptester/htmlifier

Weekly Downloads

13

Version

1.0.3

License

MIT

Unpacked Size

7.32 MB

Total Files

4

Last publish

Collaborators

  • sheeptester