These are chat archives for wooorm/remark

8th
Oct 2016
Jesse
@motleydev
Oct 08 2016 09:32
this is my parse function
function mdify(text) {
  return (0, _remark2.default, {})()
  .use(parse, {
    commonmark: true,
    footnotes: true
  })
  .use(_rehype2.default)
  .use(_wrapHeaders2.default)
  .use(stringify)
  .process(text).toString();
}
rehype is remark-rehype, parse is remark parse
Jesse
@motleydev
Oct 08 2016 09:47
correction to the above, code, I pasted failing code :)
function mdify(text) {
  return (0, _remark2.default)()
  .use(parse, {
    commonmark: true,
    footnotes: true
  })
  .use(_rehype2.default)
  .use(_wrapHeaders2.default)
  .use(stringify)
  .process(text).toString();
}
Linda_pp
@rhysd
Oct 08 2016 09:52
Hi
I'm trying to use remark-lint from my JS code. I want to specify presets in JS, is it possible? As far as I tried, below looks not working:
var fs = require('fs');
var remark = require('remark');
var lint = require('remark-lint');

remark().use(lint).process(fs.readFileSync('foo.md', 'utf8'), {
    presets: ['lint-recommended']
}, (err, done) => {
    if (err) {
        console.error(err);
        return;
    }
    console.log(done.messages);
});
Jonathan Haines
@BarryThePenguin
Oct 08 2016 09:56
@rhysd I was trying to do this the other day. You've already got 'unified-engine' in your code, I'd recommend continuing down that path
Linda_pp
@rhysd
Oct 08 2016 09:57
Thanks, I'm just trying unified-engine but it doesn't work well for me yet.
Jesse
@motleydev
Oct 08 2016 09:58

@rhysd normally the configs follow the module you are passing opts to, such as:

remark().use(lint, {
    presets: ['lint-recommended']
}).process(fs.readFileSync('foo.md', 'utf8')...

have you tried that?

Linda_pp
@rhysd
Oct 08 2016 09:59
Oh, I didn't try it. Trying now!
Jonathan Haines
@BarryThePenguin
Oct 08 2016 10:00
Hmm... I'll have to take another look!
Jesse
@motleydev
Oct 08 2016 10:01
otherwise looks like their recommendation is to use a config file.
Linda_pp
@rhysd
Oct 08 2016 10:01
@BarryThePenguin I missed extensions on calling unified-engine and now it works well with unified-engine. So your answer is also correct :smile:
Jonathan Haines
@BarryThePenguin
Oct 08 2016 10:01
yes, that would do it :smile:
Linda_pp
@rhysd
Oct 08 2016 10:03
I'm trying below now but it report nothing...
var remark = require('remark');
var lint = require('remark-lint');

remark().use(lint, {
    presets: ['lint-recommended']
}).process('* Hello\n\n[World][]\n', (err, done) => {
    if (err) {
        console.error(err);
        return;
    }
    console.log(done.messages);
});
Linda_pp
@rhysd
Oct 08 2016 10:15
Anyway, I wanted full customization from JS and unified-engine resolved it. Thank you :smiley_cat: