From: Günter M. <mi...@us...> - 2025-03-31 18:58:49
|
Thank you for the patch. On a first inspection it looks like a genuine improvement. The changes to the test suite seem to be improvements/fixes, too. Line numbers in test/functional/expected/standalone_rst_pseudoxml.txt are still incorrect (but nearer to the correct value). This needs to be looked at separately (the `<enumerated_list>` element is missing source/line internal attributes, too). We will have to look into your use-case to see whether there is still something missing in the patch or whether the problem can/must be fixed in your custom directive. --- **[patches:#213] Change section handling to not rely on exceptions and reparsing** **Status:** open **Group:** None **Created:** Wed Mar 26, 2025 07:57 PM UTC by Arne Skjærholt **Last Updated:** Mon Mar 31, 2025 01:39 PM UTC **Owner:** nobody **Attachments:** - [section-handling.patch](https://sourceforge.net/p/docutils/patches/213/attachment/section-handling.patch) (13.3 kB; text/x-patch) While waiting for responses to an email I sent to the -users I decided to dig further into the issue and ended up implementing a fix. To recap my issue, I was having problems with a custom directive's nested parse of its content when section headers were used, because the existing code throws an EOFError up the chain to find the correct place to attach a new section. The proposed patch changes this by adding an explicit stack of sections to the memo object instead of using the Python call stack, and changing RSTState.section() to unwind this state in-place, instead of using exception throwing to find the right place. In fact, I think this is the kind of implementation suggested as an alternative in a comment in the existing code. This also lets us get rid of memo.section_bubble_up_kludge and Line.eofcheck, which only existed to handle the exceptions. In addition to the changed code, I've had to make six changes to the test suite. - Three diagnostics in test/functional/expected/standalone_rst_pseudoxml.txt now have line numbers relative to the beginning of the file rather than some other element. I think because we no longer initiate a nested parse for sections. - Two diagnostics in test/test_parsers/test_rst/test_targets.py have different line numbers, indicating the second conflicting label, rather than the implicit label generated by the section. I think the reason is that due to the exception throwing approach, the existing code handled the section label later than the other, even if the section is earlier in the text. - test/test_parsers/test_rst/test_section_headers.py has one diagnostic output less. I think this diagnostic is a duplicate, caused by the rethrowing of the exception for bubbling up the stack. --- Sent from sourceforge.net because doc...@li... is subscribed to https://sourceforge.net/p/docutils/patches/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/patches/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |