Re: docutils.nodes.Node's source and line attributes
Brecht Machiels <[email protected]>
| Newsgroups | gmane.text.docutils.user |
|---|---|
| Message-ID | <991559335.166963.1389554740753.JavaMail.sas1@[172.29.241.231]> |
---- On Thu, 09 Jan 2014 00:58:45 +0100 David Goodger<[email protected]> wrote ---- > On 6 January 2014 07:50, Brecht Machiels <[email protected]> wrote: > > 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? > > Those attributes were originally meant for development and debugging > purposes. They are not guaranteed to be present on all elements, > although it would be nice if they were. You may consider it a bug. > Feel free to submit a bug report. Patches are welcome. I have created a new ticket to track this bug: https://sourceforge.net/p/docutils/bugs/245/ As this is a fairly important feature for RinohType, I will probably get around to fixing this sometime soon. I've had a quick look at the docutils code. It seems that the source and line attributes are set in the different methods corresponding to the different rST elements (states.py). I think it would be better to set these attributes at a higher lever, independent of the rST element type. However, I'm not sure where this should be implemented. Best regards, Brecht ------------------------------------------------------------------------------ CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today. http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk