Skip to content

no syntax to create line_block (hardbreak creates paragraph with raw linebreaks) #899

@eudoxos

Description

@eudoxos

What version of myst-parser are you using?

2.0.0

What version dependencies are you using?

docutils==0.20.1
sphinx==7.2.6

What operating system are you using?

Linux

Describe the Bug

MyST parser does not have proper syntax for line-block and emulates line-block by creating paragraph with hardbreaks (indicated by \ followed by linebreak). This introduces incompatibility in some (perhaps uncommon, but valid) cases. One of them is table with line-block:

# Test text block inside list-table

## list-table

```{list-table}

* - A1
  - B1 \
    in \
    3 lines 
* - A2
  - B2
```

## list-table via eval-rst

```{eval-rst}

.. list-table::

   * - A1
     - | B1
       | in
       | 3 lines
   * - A2
     - B2
```

The first table will be rendered incorrectly (as the B1 cell is a paragraph node with newlines inserted as raw latex \\ which has a different meaning inside table; whereas RST will process line_block node inside table with lines correctly).

image

image

The pseudoXML is here:

<document source="/home/eudoxos/temp/myst-br/index.md" translation_progress="{'total': 0, 'translated': 0}" xmlns:c="https://www.sphinx-doc.org/" xmlns:changeset="https://www.sphinx-doc.org/" xmlns:citation="https://www.sphinx-doc.org/" xmlns:cpp="https://www.sphinx-doc.org/" xmlns:index="https://www.sphinx-doc.org/" xmlns:js="https://www.sphinx-doc.org/" xmlns:math="https://www.sphinx-doc.org/" xmlns:py="https://www.sphinx-doc.org/" xmlns:rst="https://www.sphinx-doc.org/" xmlns:std="https://www.sphinx-doc.org/">
    <section ids="test-text-block-inside-list-table" names="test\ text\ block\ inside\ list-table">
        <title>
            Test text block inside list-table
        <section ids="list-table" names="list-table">
            <title>
                list-table
            <table>
                <tgroup cols="2">
                    <colspec colwidth="50">
                    <colspec colwidth="50">
                    <tbody>
                        <row>
                            <entry>
                                <paragraph>
                                    A1
                            <entry>
                                <paragraph>
                                    B1 
                                    <raw format="html" xml:space="preserve">
                                        <br />
                                    <raw format="latex" xml:space="preserve">
                                        \\
                                    in 
                                    <raw format="html" xml:space="preserve">
                                        <br />
                                    <raw format="latex" xml:space="preserve">
                                        \\
                                    3 lines
                        <row>
                            <entry>
                                <paragraph>
                                    A2
                            <entry>
                                <paragraph>
                                    B2
        <section ids="list-table-via-eval-rst" names="list-table\ via\ eval-rst">
            <title>
                list-table via eval-rst
            <table>
                <tgroup cols="2">
                    <colspec colwidth="50">
                    <colspec colwidth="50">
                    <tbody>
                        <row>
                            <entry>
                                <paragraph>
                                    A1
                            <entry>
                                <line_block>
                                    <line>
                                        B1
                                    <line>
                                        in
                                    <line>
                                        3 lines
                        <row>
                            <entry>
                                <paragraph>
                                    A2
                            <entry>
                                <paragraph>
                                    B2

Expected Behavior

(proposed behavior:) paragraph with hardbreaks and no softbreaks would be converted to line_block. Paragraph mixing hardbreaks and softbreaks would trigger warning. Paragraphs with softbreak only are just paragraphs.

Or alternatively, document another way of creating line_block in MyST (I did not find one).

To Reproduce

Compile the above source (saved as index.md) with this minimal conf.py:

project="test"
extensions=['myst_parser']

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions