gulp-mammoth

1.0.0 • Public • Published

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).

Package Sidebar

Install

npm i gulp-mammoth

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

62.3 kB

Total Files

21

Last publish

Collaborators

  • lgcavalheiro