Skip to content

Wrong end_line on last paragraph node #276

Closed

Description

@ekatek

Running the following code:

var commonmark = require('commonmark');
var reader = new commonmark.DocParser();
var readme =
     "X\n" +
     "---\n" +
     "Bar\n"

var parsed = reader.parse(readme);
console.log(parsed);

Results in the following:

{ t: 'Document',
start_line: 1,
start_column: 1,
end_line: 1,
children:
[ { t: 'Header',
start_line: 1,
start_column: 1,
end_line: 2,
inline_content: [Object],
level: 2,
children: [] },
{ t: 'Paragraph',
start_line: 3,
start_column: 1,
end_line: 2,
inline_content: [Object],
children: [] } ] }

On the last child, the end_line is smaller than the start_line. That doesn't seem right. In fact, it should be 1 larger than it is.

Activity

  1. jgm commented on Jan 10, 2015

    @jgm
    Member

    Thanks, I think I've fixed this now.

    Note that there have been some major changes in master.
    The parser now returns a 'Node' object, which uses doubly linked
    lists rather than arrays.

    However, you can still get something similar to the old structure by
    using the toAST() method.

    Instead of start_line, end_line, etc., we now have a pos property
    that looks like this: pos: { [start-line, start-column], [end-line] }.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions