-
Notifications
You must be signed in to change notification settings - Fork 60
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
Stringifying the terms of a definition list results in AttributeError #218
Comments
I came up with this solution:
But I don't know if it's very good or robust. I feel like there should be a built-in way to "walk" through a |
That makes sense, and might simplify some of the code Still, I wonder if that will bring unexpected problems, so I need to think a bit more on this. I also think some things might be easier if we allow BTW, unrelated but note that you are acting on a def action(elem, doc):
if isinstance(elem, pf.DefinitionList):
for item in elem.content:
term = ''.join(pf.stringify(part) for part in item.term)
definitions = '; '.join(pf.stringify(defn) for defn in item.definitions)
print(f'{term}: {definitions}') |
Hi Amine, Just added a new version https://github.com/sergiocorreia/panflute/releases/tag/v2.2.0 that should help you do what you want. Besides adding walk() to lists as you suggested, walk() also supports an optional argument This helps quite a bit when stringifying. I added a custom stringify code for definition lists which is hopefully close to what you want. Feel free to modify it (or to further improve stringify() and send a PR) |
Hi @sergiocorreia that's awesome! I'll be sure to test it out as soon as possible. With regards to the
So I basically check whether the I'll repost once I give |
Hi @sergiocorreia is there any way to install v2.2.0 using |
Thanks for catching that. The new version should have been automatically published to pypi but was not due to a weird error (it was supposed to be published with Python 3.10 but the Github workflow understands 3.10=3.1 and there's no available Python 3.1 of course). Should work not; let me know if not. |
I was able to test this and it seems to work. Closing now. |
I have the following markdown:
I try to parse and stringify the individual terms and definitons of the definition lists with
panflute
as follows:It seems that the definition print out fine, but uncommenting line 6 in the python code results in the following error:
So I suspect it is not possible to stringify
ListContainers
like that.How can I obtain the terms of my definition list using
panflute
? Thanks.The text was updated successfully, but these errors were encountered: