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

Allow 4+ spaces of indentation for image options #57

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jelmer
Copy link
Contributor

@jelmer jelmer commented Sep 24, 2024

Previously, this only supported 3.

Previously, this only supported 3.
@flying-sheep
Copy link
Owner

flying-sheep commented Nov 20, 2024

That doesn‘t work, this would wrongly accept the following:

.. image::
 :height: 1px

You need to use PEEK in some form. The current way this works is like this (<a/b/c> are placeholders for spaces, e.g. <a > is 4 spaces, <b> is 3 spaces, < c > is 9 spaces):

.. something::

<a >..<b>image::
<   c   >:height: 1px
  1. after <a >, PEEK[..] is [\s\s\s\s]
  2. after image::, PEEK[..] is [\s\s\s\s, \s\s\s] (indentation <a > and then the spaces after the “..” <b>)
  3. after < c >, PEEK[..] is [\s\s\s\s, \s\s\s\s\s], because the PUSH(POP ~ " ") modified the last entry of the stack, adding 2 spaces.

so c contains the 4 spaces from the indentation <a >, and then the (3+2) spaces from the “..” and after.

@jelmer
Copy link
Contributor Author

jelmer commented Nov 20, 2024

That doesn‘t work, this would wrongly accept the following:

.. image::
 :height: 1px

That's valid though? rst2html happily accepts this:

.. image:: foo.png
 :height: 1px

turning it into:

<img alt="foo.png" src="foo.png" style="height: 1px;" />

@flying-sheep
Copy link
Owner

flying-sheep commented Nov 20, 2024

Ugly but OK. Can you add a test like this that checks that it parses similar to the below? (doesn’t need to create a warning, we don’t support that yet)

.. pull-quote::
   .. image:: foo.png
 :height: 1px
rst2pseudoxml image.rst
image.rst:3: (WARNING/2) Block quote ends without a blank line; unexpected unindent.
<document source="image.rst">
    <block_quote classes="pull-quote">
        <block_quote>
            <image uri="foo.png">
        <system_message level="2" line="3" source="image.rst" type="WARNING">
            <paragraph>
                Block quote ends without a blank line; unexpected unindent.
        <field_list>
            <field>
                <field_name>
                    height
                <field_body>
                    <paragraph>
                        1px

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants