1.0.0 • Published 3 years ago

gulp-mammoth v1.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
3 years ago

Gulp-mammoth

code style: prettier Build Status Coverage Status

Gulp plugin that converts Word documents to html or markdown files using mammoth.js


Basic usage

const gulp = require("gulp");
const series = gulp.series;

const mammoth = require("../src/index");

function basicUsage() {
    return gulp.src("./data/nonEmpty.docx").pipe(mammoth("html")).pipe(gulp.dest("./results"));
}

module.exports.default = series(basicUsage);

Usage example with gulp-if

const gulp = require("gulp");
const gulpIf = require("gulp-if");
const series = gulp.series;

const mammoth = require("../src/index");

function withGulpIf() {
    return gulp
        .src("./data/*")
        .pipe(gulpIf(file => file.basename.toLowerCase().includes("html"), mammoth("html")))
        .pipe(gulpIf(file => file.basename.toLowerCase().includes("markdown"), mammoth("md")))
        .pipe(gulpIf(file => file.basename.toLowerCase().includes("text"), mammoth("txt")))
        .pipe(gulp.dest("./results"));
}

module.exports.default = series(withGulpIf);

All usage examples can be found on example folder and can be executed with yarn gulp --gulpfile ./example/name_of_file.gulpfile.js

Running tests

You can use yarn test to run the test suite once, or you can run yarn gulp inside the root of the project to activate continuous TDD (it will run the tests every time a file is updated).