Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rst writer: indentation problem with BlockQuote at beginning of list item #10236

Closed
PhilipPartsch opened this issue Sep 28, 2024 · 15 comments
Closed

Comments

@PhilipPartsch
Copy link

Explain the problem.
I'm using rst writer with list-tables.
If the content of a cell is a BlockQuote, the indention of the block looks wrong in the rst output.

Input:

  , Table
      ( "" , [] , [] )
      (Caption Nothing [])
      [ ( AlignLeft , ColWidth 0.2582188930503537 )
      , ( AlignLeft , ColWidth 0.7417811069496463 )
      ]
      (TableHead ( "" , [] , [] ) [])
      [ TableBody
          ( "" , [] , [] )
          (RowHeadColumns 0)
          []
          [ Row
              ( "" , [] , [] )
              [ Cell
                  ( "" , [] , [] )
                  AlignLeft
                  (RowSpan 1)
                  (ColSpan 1)
                  [ BlockQuote
                      [ Para [ Emph [ Str "Level" , Space , Str "0:" ] ]
                      , Para [ Emph [ Str "Incomplete" , Space , Str "process" ] ]
                      ]
                  ]

Current output:

.. list-table::
   :widths: 26 74

   - 

      - *Level 0:*

            *Incomplete process*

Expected output:

.. list-table::
   :widths: 26 74

   - 

      - *Level 0:*

        *Incomplete process*

I cannot identify the wrong code line, but the transformation of the BLockQuote looks fine see.

Maybe it is some where in the table processing.
From the logic, even following output would be fine:

.. list-table::
   :widths: 26 74

   - 

      -    *Level 0:*

           *Incomplete process*

I'm even not sure if it is fixed with commit.

I even fear, if we change here the processing, that the output of classical tables breaks.
As it works for these:

+------------------------+-------------------------------------------------------------------------+
|    *Level 0:*          | *The process is not implemented or fails to achieve its process         |
|                        | purpose.*                                                               |
|    *Incomplete         |                                                                         |
|    process*            |                                                                         |
+------------------------+-------------------------------------------------------------------------+

Pandoc version?
3.4

@jgm
Copy link
Owner

jgm commented Sep 28, 2024

I think the commit you reference did fix this.
Try with a nightly?

@PhilipPartsch
Copy link
Author

For me it is not working with the nightly build.

I used this version:
Nightly #1807
See

Current output:

.. list-table::
   :widths: 26 74

   * - *Level 0:*

          *Incomplete process*
     - *The process is not implemented or fails to achieve its process purpose.*

@jgm
Copy link
Owner

jgm commented Sep 30, 2024

OK, thanks, can you give me a complete input to test with (the one above is not complete)?

@jgm
Copy link
Owner

jgm commented Sep 30, 2024

Never mind, was able to get this by converting your expected output:

[ Table
    ( "" , [] , [] )
    (Caption Nothing [])
    [ ( AlignDefault , ColWidth 0.26 ) ]
    (TableHead ( "" , [] , [] ) [])
    [ TableBody
        ( "" , [] , [] )
        (RowHeadColumns 0)
        []
        [ Row
            ( "" , [] , [] )
            [ Cell
                ( "" , [] , [] )
                AlignDefault
                (RowSpan 1)
                (ColSpan 1)
                [ BlockQuote
                  [ Para [ Emph [ Str "Level" , Space , Str "0:" ] ]
                  , Para
                      [ Emph [ Str "Incomplete" , Space , Str "process" ]
                      ]
                  ]
                ]
            ]
        ]
    ]
    (TableFoot ( "" , [] , [] ) [])
]

@jgm
Copy link
Owner

jgm commented Sep 30, 2024

OK, this is not specific to list tables. Here's a test case with a regular list containing a block quote:

%  pandoc -f markdown -t rst
- > test
  >
  > more
- ok
^D
-  test

      more

-  ok

@jgm jgm changed the title rst writer with --list-tables=true: BlockQuote is not aligned in the rst output rst writer: indentation problem with BlockQuote at beginning of list item Sep 30, 2024
@jgm
Copy link
Owner

jgm commented Sep 30, 2024

The question is how you are supposed to represent this in RST. I tried

-    *Level 0:*

     *Incomplete process*

with docutils rst2html and got

<ul>
<li><p class="first"><em>Level 0:</em></p>
<p><em>Incomplete process</em></p>
</li>
</ul>

Does RST actually have any way of representing a block quote at the beginning of a list item?

@PhilipPartsch
Copy link
Author

I have created an example, which works for me:

Syntax which works fine
-----------------------

Text:

   Quoted Block 1

      Quoted Block 2

List:

-  \ 

      Quoted Block 1

         Quoted Block 2

Table:

.. list-table::

   * - \ 

          Quoted Block 1

             Quoted Block 2

As you can see, I'm adding a hidden text block with \ .

html output:

<section id="syntax-which-works-fine">
<h2>Syntax which works fine<a class="headerlink" href="#syntax-which-works-fine" title="Link to this heading"></a></h2>
<p>Text:</p>
<blockquote>
<div><p>Quoted Block 1</p>
<blockquote>
<div><p>Quoted Block 2</p>
</div></blockquote>
</div></blockquote>
<p>List:</p>
<ul>
<li><p></p>
<blockquote>
<div><p>Quoted Block 1</p>
<blockquote>
<div><p>Quoted Block 2</p>
</div></blockquote>
</div></blockquote>
</li>
</ul>
<p>Table:</p>
<table class="docutils align-default">
<tbody>
<tr class="row-odd"><td><p></p>
<blockquote>
<div><p>Quoted Block 1</p>
<blockquote>
<div><p>Quoted Block 2</p>
</div></blockquote>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
</section>

Here rendered as a web page. In Safari, it looks not so good, but in Firefox it is fine. (I suggest to scroll down in Safari, to detect that Safari is not correctly indenting the <blockquote> in the list.

Here is a link to a playground repository, where the rst code is available and render with sphinx/docutils to above page. In GitHub, the quoted blocks are even rendered correct in the preview.

I cannot ensure, that the side is available long time.

@jgm
Copy link
Owner

jgm commented Sep 30, 2024

But then you also have an empty paragraph. So, semantically it is not the same...

@jgm
Copy link
Owner

jgm commented Sep 30, 2024

This works better:

* ..

    block quote

rst2html gives:

<ul>
<li><!--  -->
<blockquote>
<p>block quote</p>
</blockquote>
</li>
</ul>

@PhilipPartsch
Copy link
Author

PhilipPartsch commented Sep 30, 2024

Have the same solution.
Rst:

With an empty comment
---------------------

List:

-  .. 

      Quoted Block 1

         Quoted Block 2

Table:

.. list-table::

   * - ..

          Quoted Block 1

             Quoted Block 2

html:

<section id="with-an-empty-comment">
<h2>With an empty comment<a class="headerlink" href="#with-an-empty-comment" title="Link to this heading"></a></h2>
<p>List:</p>
<ul>
<li><blockquote>
<div><p>Quoted Block 1</p>
<blockquote>
<div><p>Quoted Block 2</p>
</div></blockquote>
</div></blockquote>
</li>
</ul>
<p>Table:</p>
<table class="docutils align-default">
<tbody>
<tr class="row-odd"><td><blockquote>
<div><p>Quoted Block 1</p>
<blockquote>
<div><p>Quoted Block 2</p>
</div></blockquote>
</div></blockquote>
</td>
</tr>
</tbody>
</table>

@PhilipPartsch
Copy link
Author

But how does Pandoc translate the empty comment in the native model?
Or are we now good enough?

@jgm
Copy link
Owner

jgm commented Sep 30, 2024

It will just be ignored.
I think it's good enough.

jgm added a commit that referenced this issue Sep 30, 2024
In these cases we emit an empty comment to fix the point from
which indentation is measured; otherwise the block quote is not
parsed as a block quote.

This affects list items and admonitions.

Cloess #10236.
@jgm jgm closed this as completed Sep 30, 2024
@PhilipPartsch
Copy link
Author

It is still not working, even with the nightly build . Maybe we missed the list-tables?

@jgm
Copy link
Owner

jgm commented Oct 1, 2024

Sorry, yes -- I hadn't realized that list tables didn't reuse the code for lists! Will fix.

@jgm jgm reopened this Oct 1, 2024
jgm added a commit that referenced this issue Oct 1, 2024
With this patch, we also reuse bullet list code for list tables,
which simplifies the code.
@jgm
Copy link
Owner

jgm commented Oct 1, 2024

OK it should work now.

@jgm jgm closed this as completed Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants