To my surprise, wikicode.get_parent() does not get you the section a node is 
part of:

> import mwparserfromhell as mwp
> 
> text = """==foo==
> {{Template:Foo}}
> """
> wikicode = mwp.parse(text)
> print(wikicode.get_tree())
> 
> print('++++++++++')
> 
> node = wikicode.nodes[-2]
> print(f"{node=}")
> print(f"{wikicode.get_parent(node)=}")

prints:

> ==
>       foo
> ==
> \n
> {{
>       Template:Foo
> }}
> \n
> ++++++++++
> node='{{Template:Foo}}'
> wikicode.get_parent(node)=None

Am I just doing this wrong?
_______________________________________________
pywikibot mailing list -- pywikibot@lists.wikimedia.org
Public archives at 
https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/message/ZFCIVR24X5L4SYPFA4KKGU3YQTODPS3E/
To unsubscribe send an email to pywikibot-le...@lists.wikimedia.org

Reply via email to