Skip to content

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

License

Notifications You must be signed in to change notification settings

lgcavalheiro/gulp-mammoth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published