9

using code like this:

var remarkAbstract = require("remark");
var remark = remarkAbstract();

let remark = remarkAbstract();
var ast = remark.process(input);

but it returns output like:

AssertionError: VFile {
  contents: '# header\n\n20 December 2012\n\n![alt](http://yo.io/)\n\ncontent1\n\ncontent2\n\n## header2\n',
  messages: =

I'd like to get AST tree like this

Alex Filatov
  • 2,232
  • 3
  • 32
  • 39

1 Answers1

8

By replacing remark.process(input) with remark.parse(input).

P.S. Also, this is not a very good question for StackOverflow. I suggest reading up on that :)

  • 5
    I have the same issue and I've read the docs of `remark`, but the docs seems too simple, not cover how to get ast. – user2331095 Jun 11 '17 at 23:49
  • The Q/A on this question, [How to parse markdown to json using remark](https://stackoverflow.com/a/70466143/418950), may help. – ScottWelker Dec 30 '21 at 17:23