sparkartgroup / gulp-markdown-to-json

Parse Markdown and YAML → compile Markdown to HTML → wrap it all up in JSON
MIT License
75 stars 14 forks source link

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

Open shawn-sandy opened 6 years ago

shawn-sandy commented 6 years ago

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/'))
})
gerardkeane commented 6 years ago

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

gerardkeane commented 6 years ago

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.

mildrenben commented 5 years ago

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