Brecht Machiels
2014-01-06 13:50:10 UTC
Hello,
I'm using reStructuredText as an input format for RinohType [1]. Since I want to provide useful warning/error messages, I rely on the source, tagname and line attributes of the Node instances to point the user to the relevant location in the source file.
I have noticed that not all Node instances have non-None source and/or line attributes. For example, the following nodes (among others) in the quickstart.txt [2] have missing data:
* literal_block at line 119: document is None
* enumerated_list at line 143: both document and line are None
* bullet_list at line 179: both document and line are None
* literal_block at line 193: document is None
* literal_block at line 236: document is None
Some other literal_block nodes do have document set though.
Is this normal behavior? I don't remember if I found out about source/line by reading the documentation or by reading nodes.py. I can't seem to find a description the docs at this moment.
For now, if document is None, I (recursively) try to get the document from the parent node. Same for line.
[1] http://www.mos6581.org/introducing-rinohtype
[2] http://docutils.sourceforge.net/docs/user/rst/quickstart.txt
Best regards,
Brecht
I'm using reStructuredText as an input format for RinohType [1]. Since I want to provide useful warning/error messages, I rely on the source, tagname and line attributes of the Node instances to point the user to the relevant location in the source file.
I have noticed that not all Node instances have non-None source and/or line attributes. For example, the following nodes (among others) in the quickstart.txt [2] have missing data:
* literal_block at line 119: document is None
* enumerated_list at line 143: both document and line are None
* bullet_list at line 179: both document and line are None
* literal_block at line 193: document is None
* literal_block at line 236: document is None
Some other literal_block nodes do have document set though.
Is this normal behavior? I don't remember if I found out about source/line by reading the documentation or by reading nodes.py. I can't seem to find a description the docs at this moment.
For now, if document is None, I (recursively) try to get the document from the parent node. Same for line.
[1] http://www.mos6581.org/introducing-rinohtype
[2] http://docutils.sourceforge.net/docs/user/rst/quickstart.txt
Best regards,
Brecht