mixu / markdown-styles

Markdown to static HTML generator and multiple CSS themes for Markdown
1.85k stars 250 forks source link

Programmatic usage? #14

Closed tomek-he-him closed 9 years ago

tomek-he-him commented 9 years ago

Hi, is there a programmatic API?

I generate my markdown docs using gulp, and your library seems perfect for giving them a little colour. But spawning command line programs is against the spirit of gulp.

I'd be happy to write a gulp plugin for your library when I have some time – if you document the programmatic API.

mixu commented 9 years ago

With the new v2.0 release, an API is included, though I need to still work on the docs. If you look at the new bin/generate-md, you'll see it calls resolveArgs(opts) then render(opts, [onDone]). These two functions are exported in https://github.com/mixu/markdown-styles/blob/master/lib/index.js

There's also a pipeline() function which should work with gulp with a few minor input modifications, it returns a object mode stream (via through2/pipe-iterators) that takes file objects with these properties: https://github.com/mixu/markdown-styles/blob/master/lib/stream/read.js and so gulp files can probably be converted to the right input with a few field renames.

Will close this once I have some time to do API docs but figured I'd let you know this is mostly done.

tomek-he-him commented 9 years ago

Thank you! I'm anxious :)

I have a ton of todos at the moment, so I'm perfectly ok to wait.

jussimattila commented 9 years ago

Do you have more docs on this now? I'd be interested to integrate HTML doc generation to my gulp process.

mixu commented 9 years ago

docs added!

mixu commented 9 years ago

let me know if there are any areas that need more docs or send a PR with further improvements if you notice something is missing

tomek-he-him commented 9 years ago

:+1:

tomek-he-him commented 9 years ago

Thanks for taking the time to do this! I’ve promised you a gulp plugin – but we no longer use gulp extensively.

If I find some time, I’ll be happy to help – but please don’t take that as a promise :)

jussimattila commented 9 years ago

Thanks a lot! I managed to make it work with gulp based on the source code, but with your example, I'll be able to simplify my task a bit. :-)