-
-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect AST for lists #457
Comments
This is a bit unfortunate; the field description is a bit of a misnomer. We decided to publicise node data private fields in #216(/#215), since it was otherwise impossible to programmatically construct an AST. But the one-line description of (Thus your first example gives all zeroes since each (sub)list is as far to the left as it could be while representing the same structure.) Open to suggestions for a better comment describing the field, but as the value is depended-upon (primarily by The AST does not currently store enough information to recover what you're looking for1: it is not a concrete syntax tree, although that's increasingly being called for! Footnotes
|
Thanks for the clarification. I guess the upshot is that unless you're generating HTML you need to keep track of state (the depth of lists) while walking the tree, because the nodes don't have sufficient information by themselves. I was misled by the fact that the |
Yep! |
There seems to be a problem with the AST Comrak's
parse_document
function generates for lists. Specifically, the value of the NodeList object'smarker_offset
isn't set as it should be for sub-lists.The expected behavior is that in a Markdown list, a line with an item marker that is indented by some multiple of two spaces will start a sub-list, and that that sub-list's
marker_offset
will indicate the level.As an example of unexpected AST, the following Markdown will correctly result in three lists, but the value in each one's
marker_offset
will be zero.After some experimenting, it appears that some number of leading spaces can be used in the sublists that will result in the library generating the expected values: To start the first sub-level in a list (
marker_offset == 1
) a line must be indented three spaces; to start a second level (marker_offset == 2
) requires seven spaces, and the forth level (marker_offet == 3
) needs 12. It doesn't look like any number of leading spaces will result in amarker_offset
greater than 3.Here's an example:
The text was updated successfully, but these errors were encountered: