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

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

Closed
eudoxos opened this issue Mar 31, 2024 · 4 comments · Fixed by #900
Closed

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

eudoxos opened this issue Mar 31, 2024 · 4 comments · Fixed by #900
Labels
bug Something isn't working

Comments

@eudoxos
Copy link

eudoxos commented Mar 31, 2024

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']
@eudoxos eudoxos added the bug Something isn't working label Mar 31, 2024
@chrisjsewell
Copy link
Member

I believe #900 closes this 😄 see updated https://myst-parser.readthedocs.io/en/latest/syntax/typography.html#line-breaks

@eudoxos
Copy link
Author

eudoxos commented Mar 31, 2024

Oh, quite a co-incidence in time :) Can one use the new line-block directive inside a list-table item? I am not sure.

@eudoxos
Copy link
Author

eudoxos commented Mar 31, 2024

Related: #877 (paragraph with raw breaks does not work with a custom builder)

@chrisjsewell
Copy link
Member

chrisjsewell commented Mar 31, 2024

Oh, quite a co-incidence in time :)

If by coincidence, you mean I saw this issue and then fixed it 😄

Can one use the new line-block directive inside a list-table item?

yes you can 👍

I'll close this as fixed, but feel free to re-open or open a new issue, if there is anything else

@chrisjsewell chrisjsewell linked a pull request Mar 31, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants