File2html Save Abandoned

JS convertor of files to HTML and CSS code

Project README

file2html

Build Statusnpm npm npm Coverage Status

JS convertor of files to HTML and CSS code

Requirements

Supported formats

Usage

Installation

> npm i file2html

Installation of required engines for each file type:

> npm i file2html-text file2html-ooxml file2html-image 

Check supported formats to decide which engines you need.

Configuration

import * as file2html from 'file2html';
import TextReader from 'file2html-text';
import OOXMLReader from 'file2html-ooxml';
import ImageReader from 'file2html-image';

file2html.config({
    readers: [
        TextReader,
        OOXMLReader,
        ImageReader
    ]
});

File reading

file2html.read({
    fileBuffer, // ArrayBuffer
    meta // file2html.FileMetaInformation
}).then((file) => {
    // file is an instance of file2html.File type 
    const {styles, content} = file.getData();    
    
    // "render" a file content with styles
    document.body.innerHTML = styles + content;
});

FileMetaInformation

    {
        fileType: number; // optional
        mimeType: string; // optional
        name: string; // optional
        size: number; // optional
        creator: string; // optional
        createdAt: string; // optional
        modifiedAt: string; // optional
    }

File

    {
        getMeta () {
            // returns object of file2html.FileMetaInformation    
        }
    
        getData ()  {
            // returns object of file2html.FileData
        }
    }

FileData

    {
        meta: file2html.FileMetaInformation;
        styles: string; // css styles as a string
        content: string; // html markup as a string
    }

Showcase

StormFiles

Browser extension, file viewer:

Open Source Agenda is not affiliated with "File2html" Project. README Source: file2html/file2html
Stars
28
Open Issues
1
Last Commit
3 years ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating