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

The warning admonition not enforcing line breaks #12881

Open
pique-b opened this issue Sep 11, 2024 · 4 comments
Open

The warning admonition not enforcing line breaks #12881

pique-b opened this issue Sep 11, 2024 · 4 comments

Comments

@pique-b
Copy link

pique-b commented Sep 11, 2024

Describe the bug

While using admonition warning in my Sphinx doument, I find that a general sentence with a number of words (so as to be longer than the boundary of the admonition to be accommodated) line breaks are enforced once reaching the admonition boundary scope:

An example:

Let's consider the above paragraph itself, the line break has been enforced as we have reached the word/s to be (as in ... (so as to be (may be different for different screen size and resolution!). Actually what I have experienced is that, Sphinx (RestructuredText) goes a step beyond and is able to add line break if it encounters a word that is comprised of a number of letters and applies the line break by breaking up the word.

Whereas if I am to add a longish URL the same effect is not observed (i.e. no line break is applied once the string of texts reaches the admonition's boundary).

Here is an image of what I have described above:

admonition_no_line_brk

As we can see the URL string has travelled beyond the boundary of the admonition.

How to Reproduce

I have used the minimal settings in my conf.py file.

The warning directive as being used is reproduced below:

.. warning::

   #. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamcoabcdefghijkl laboris nisi ut aliquip

   #. https://www.amazon.com/s?k=high+end+speakers&crid=1N7I9DZEJL9QJ&sprefix=highend+speakers%2Caps%2C522&ref=nb_sb_ss_ts-doa-p_1_16

Environment Information

Sphinx ver 7.2.6
Python 3.9

Sphinx extensions

Only the bare bone that are recommended.

Additional context

So my question is:

  • How do I resolve the issue described above
  • Is this a bug, and if it is, what steps one needs to take to overcome that
@jayaddison
Copy link
Contributor

Further investigation required, but this seems potentially related to: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_text/Wrapping_breaking_text

@pique-b
Copy link
Author

pique-b commented Sep 11, 2024

@jayaddison Thanks for sharing the link which was quite informative (and fun too). But to my mind, if Sphinx / reST is able to identify a situation when a particular word might overflow and needed to be broken up, why is it that somehow the long string of URL (as shown above) is not broken up, at the point where it tends to overflow the bounds?

@electric-coder
Copy link

why is it that somehow the long string of URL (as shown above) is not broken up

Possibly because the URL gets transformed into an href instead of being standard text and thus has to be targeted with custom CSS that might not be implemented.

@pique-b
Copy link
Author

pique-b commented Sep 14, 2024

Possibly because the URL gets transformed into an href instead of being standard text

I find that tweaking a file path a litlle also has the effct as described above. In the example below notice how even a little addition gets in the way of correctly(?) rendering the admonition:

The example:

admon_no_lin_brk_2nd

And in the directive:

.. warning::

   WARNING: Notebook exception traceback saved in: 

   /Users/abcdefghijklmnopqrs/Desktop/PY_PY/py_py_vnv/proj_py_dream/build/html/reports/blame_it_on_rio/imageAI.err.log [mystnb.exec]

   WARNING: Notebook exception traceback saved in: 

   /Users/abcdefghijklmnopqrs/abcdefgh/Desktop/PY_PY/py_py_vnv/proj_py_dream/build/html/reports/blame_it_on_rio/imageAI.err.log [mystnb.exec]

Both are essentially the same, except in the second I added a bunch of random letters /abcdefgh just to see how it played out - but again the second example did overflow the bounds.

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

3 participants