gulp-markdown-to-json icon indicating copy to clipboard operation
gulp-markdown-to-json copied to clipboard

Outputs json converted *.md files no *.json or wont compile into single *. json?

Open shawn-sandy opened this issue 6 years ago • 3 comments

The gulp task returns *.md no *.json output the code is below,

Thanks for your help


const gulp = require('gulp')
const marked = require('marked')
const listStream = require('list-stream');

marked.setOptions({
  pedantic: true,
  smartypants: true
})


gulp.task('markdown-json', () => {
  gulp.src([
      './src/packages/**/**/*.md',
      '!./src/packages/**/node_modules/**/*.md'
    ])
    .pipe(jsonMarkdown(marked))
    .pipe(gulp.dest('dist/docs/json/'))
})

single output file task/config


gulp.task('markdown-json', () => {
  gulp.src([
      './src/packages/**/**/*.md',
      '!./src/packages/**/node_modules/**/*.md'
    ])
    .pipe(listStream.obj())
    .pipe(jsonMarkdown(marked))
    .pipe(gulp.dest('dist/docs/json/'))
})

shawn-sandy avatar Jul 10 '18 03:07 shawn-sandy

I have the same issue. Everything works correctly but the file extension of the output file is .md rather than .json.

gerardkeane avatar Aug 31 '18 12:08 gerardkeane

I forgot to say, the gulp-rename package can probably help here:

https://www.npmjs.com/package/gulp-rename

var rename = require('gulp-rename')

gulp.task('markdown-json', () => {
  gulp.src([
      './src/packages/**/**/*.md',
      '!./src/packages/**/node_modules/**/*.md'
    ])
    .pipe(jsonMarkdown(marked))
    .pipe(rename({ extname: '.json' }))
    .pipe(gulp.dest('dist/docs/json/'))
})

I'm using it for something else but it should be a simple solution.

gerardkeane avatar Sep 14 '18 08:09 gerardkeane

Appears this bug was introduced in v1.1.0. Going back to v1.0.3 fixes this. (gulp-rename is also a solution)

mildrenben avatar Sep 30 '19 12:09 mildrenben