pressbooks-book
pressbooks-book copied to clipboard
Paragraphs after images do not indent in webbook and PDF formats
Description
Paragraphs that begin directly after an image in the body of the text do not indent, even when the Paragraph Separation setting is set to "Indented paragraphs."
This occurs in all tested themes (incl in testing: Adunis, Andreesen, Bradbury, McLUhan).
The issue affects the webbook and PDF formats, but not ebook.
Example: https://paragraphafterimage.textopress.com
Steps to Reproduce
- Create a chapter and add an image
- Add at least one paragraph after that chapter
- Go to Appearance > Theme Options and save the Paragraph Separation setting as "Indent Paragraphs"
- Export and view in web and PDF formats
Expected behavior: All paragraphs adhere to the paragraph style set in the theme options
Actual behavior: Paragraphs after images will not indent
The issue here is the the text indentation rule targets .chapter p + p
elements only (see https://github.com/pressbooks/pressbooks-book/blob/46e41fb60b177edf3db32991e8561a5bc35899bd/packages/buckram/assets/styles/components/elements/_paragraphs.scss#L20) and paragraphs that occur after images don't match the pattern, because the image element is usually wrapped inside of a div or figure. We have a rule that accounts for paragraphs which follow floated elements (https://github.com/pressbooks/pressbooks-book/blob/46e41fb60b177edf3db32991e8561a5bc35899bd/packages/buckram/assets/styles/components/elements/_paragraphs.scss#L47-L68) but this doesn't catch paragraphs which follow non-aligned image elements. Perhaps the original rule could be changed to .chapter * + p
?
Basically, we need to make sure we're catching paragraphs which follow images with the alignnone property set.