gulp-ljs

Literate Javascript Gulp plugin.

Usage no npm install needed!

<script type="module">
  import gulpLjs from 'https://cdn.skypack.dev/gulp-ljs';
</script>

README

gulp-ljs

This is a gulp plugin for ljs - Literate Javascript. Note, that there are two ways of literating your code:

  • .lit.js -> .md and .lit.js -> .js (see literate)
  • .js -> .md *THIS*

Everything inside /* and */ is handled as markup. Your code will be transformed into the markup code environment. Just to give you an idea:

/*
   # Literate me :-)
   Prosa..
   * item1
   * item2
*/
var awesome = "Awesome";
console.log(awesome);

Usage

Install gulp-ljs:

npm install gulp-ljs --save-dev

Using this plugin is pretty straight forward. For the sake of sanity I replace the extension of the filepath automatically.

var ljs = require('gulp-ljs');

gulp.task('literate', function () {
  gulp.src('path/**/*.js')
    .pipe(ljs())
    .pipe(gulp.dest('path/')) // writes *.md
});

Options

code

Don't include the code in the markup file. Default: true

var ljs = require('gulp-ljs');

gulp.task('literate', function () {
  gulp.src('path/**/*.js')
    .pipe(ljs({code : false}))
    .pipe(gulp.dest('path/'))
});