Menu

#341 "unexpected indent" warning does note cite most recent mark-up construct

closed-rejected
nobody
None
5
2020-03-03
2018-01-24
jfbu
No

Consider this test:

======
 TEST
======

First case:

This will output::

  b'1
'

Second case:

        This will output::

          b'1
'

Then:

$ rst2html.py test.rst test.html
test.rst:10: (WARNING/2) Literal block ends without a blank line; unexpected unindent.
test.rst:17: (WARNING/2) Block quote ends without a blank line; unexpected unindent.

In second case, it may divert user from root cause. Real life example comes from unescaped backslashes in a docstring, https://github.com/sphinx-doc/sphinx/issues/4479

Because the docstrings has the spaces naturally, the "Block quote ends without a blank line" warning was emitted. This led to further confusion with quotes as in typographical quotes, (of course that's not due to Docutils ;-)), and I guess perhaps user could have found the explanation easier if message had been of type "Literal block ends without...".

Discussion

  • Günter Milde

    Günter Milde - 2018-01-24
    • status: open --> pending-works-for-me
     
  • Günter Milde

    Günter Milde - 2018-01-24

    This is expected behaviour: The indentation of the next paragraph determines whether it ends the outer block element or a nested block element. The following example should make this clear:

    Standard paragraph
    
       * List 
       * in a quote
    next paragraph (not nested)
    
       * List 
       * in a quote
       next paragraph (nested)
    
    next paragraph (not nested) 
    

    The non-nested paragraph ends the block-quote while the nested paragraph just ends the list (at least this is what they will do if properly separated.

    I agree that the original issue is unfortunately hard to detect. Backslashes in docstrings are a trap. However, the remedy here is IMO proper documentation of the Python string handling and an advise to print docstrings out via Python in case of problems -- to see how they reach Sphinx/Docutils.

     
  • Günter Milde

    Günter Milde - 2018-11-29
    • status: pending-works-for-me --> closed-rejected
     

Log in to post a comment.