-
Notifications
You must be signed in to change notification settings - Fork 119
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
Surprising Heading.content #99
Comments
Hi, this really is the expected behavior. Because by writing If you want to know how to access the parsed structure, the best is probably to run mistletoe with the {
"type": "Document",
"footnotes": {},
"children": [
{
"type": "Heading",
"level": 1,
"children": [
{
"type": "RawText",
"content": "My first title"
}
]
},
{
"type": "Paragraph",
"children": [
{
"type": "RawText",
"content": "Some text."
}
]
},
{
"type": "Heading",
"level": 1,
"children": [
{
"type": "RawText",
"content": "My second title"
}
]
},
{
"type": "Paragraph",
"children": [
{
"type": "RawText",
"content": "Some more text."
}
]
}
]
} (BTW You should remove trailing spaces from your example markdown code - or one gets Code blocks parsed otherwise.) |
Ok, thanks for the explanation. Feel free to close this issue, but I think some more documentation would be helpful here. I don't think it is such an exotic thing to do (I wanted to make the first h1 into the title of the whole thing in some metadata associated to the file). |
@PatrickMassot, you're welcome. :) I'm not this project's maintainer though, so I can't close this issue. Anyway, I agree with you this could be documented, probably on the Contributing page... |
Now when I can contribute to the project directly, I added a corresponding chapter Understanding the AST in 14a0d9e. I hope that could suffice. Suggestions welcome. :) |
In the following code, I was expecting to see my two titles printed.
But this prints the second title twice. To get the result I expected, I need to write
print(doc.children[0].children[0].content, doc.children[2].children[0].content)
. I don't know if this is a bug or expected behavior, but I justed wasted half an hour on this.The text was updated successfully, but these errors were encountered: