emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] Edge case for preview image alignment
@ 2025-01-09 21:38 Karthik Chikmagalur
  2025-01-10 18:55 ` Ihor Radchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Karthik Chikmagalur @ 2025-01-09 21:38 UTC (permalink / raw)
  To: emacs-orgmode

Currently the value of `org-image-align' or of the `:align' attr_*
keyword is respected when previewing images in the following two
situations:

1. Image link in its own paragraph:

#+attr_org: :align center
[[file:/path/to/image.png]]

2. Image link at the end of a paragraph, on its own line:

Some text in a paragraph
#+attr_org: :align center
[[file:/path/to/image.png]]

OR

Some text in a paragraph
[[file:/path/to/image.png]]

But it is ignored when the 

3. image link is on its own line "inside" a paragraph:

Some text in a paragraph
#+attr_org: :align center
[[file:/path/to/image.png]]
followed by more text in the paragraph.

OR

Some text in a paragraph
[[file:/path/to/image.png]]
followed by more text in the paragraph.

-------

In contrast, the value of `org-image-max-width',
`org-image-actual-width' (and the attr_* :width attribute) are respected
in all three cases.

Should we support image alignment in case 3?

The only situation in which I can see this being undesirable is when you
have hard-wrapped/filled lines and the image link coincidentally ends up
on its own line.  In this case it doesn't make sense for the image
preview to respect `org-image-align'.  There might be other syntactical
reasons why supporting case 3 doesn't make sense, so I am asking here.

Karthik


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [BUG] Edge case for preview image alignment
  2025-01-09 21:38 [BUG] Edge case for preview image alignment Karthik Chikmagalur
@ 2025-01-10 18:55 ` Ihor Radchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2025-01-10 18:55 UTC (permalink / raw)
  To: Karthik Chikmagalur; +Cc: emacs-orgmode

Karthik Chikmagalur <karthikchikmagalur@gmail.com> writes:

> Currently the value of `org-image-align' or of the `:align' attr_*
> keyword is respected when previewing images in the following two
> situations:
>
> 1. Image link in its own paragraph:
>
> #+attr_org: :align center
> [[file:/path/to/image.png]]
>
> 2. Image link at the end of a paragraph, on its own line:
>
> Some text in a paragraph
> #+attr_org: :align center
> [[file:/path/to/image.png]]

These two situations are the same - standalone image in a paragraph.
The second example is _two_ paragraphs. (affiliated keywords force-start
a new paragraph)

> OR
>
> Some text in a paragraph
> [[file:/path/to/image.png]]

This will be ignored.

> But it is ignored when the 
>
> 3. image link is on its own line "inside" a paragraph:
>
> Some text in a paragraph
> #+attr_org: :align center
> [[file:/path/to/image.png]]
> followed by more text in the paragraph.

This is the same as just

#+attr_org: :align center
[[file:/path/to/image.png]]
followed by more text in the paragraph.

> In contrast, the value of `org-image-max-width',
> `org-image-actual-width' (and the attr_* :width attribute) are respected
> in all three cases.

Sure. Because it works for both inline and standalone images, unlike
org-image-align:

    org-image-align is a customizable variable defined in ol.el.
    ...
    Documentation
    How to align images previewed using org-link-preview-region.
    
    Only stand-alone image links are affected by this setting.  These
    are links without surrounding text.

> Should we support image alignment in case 3?
>
> The only situation in which I can see this being undesirable is when you
> have hard-wrapped/filled lines and the image link coincidentally ends up
> on its own line.  In this case it doesn't make sense for the image
> preview to respect `org-image-align'.  There might be other syntactical
> reasons why supporting case 3 doesn't make sense, so I am asking here.

Maybe. Or not.

Alignment is intersecting its syntax with export.
But export will only align truly standalone images.
There will be no notion of "image in a line of its own in the middle of
paragraph"

Also, what would you do if there are multiple images like that or when
the purpose of :align attribute is to align the whole paragraph?

Consider something like

# Align the whole paragraph
#+attr_html: :align center
Paragraph with inlined
[[file:image.png]]
image and
[[file:image2.png]]
another one.

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-01-10 19:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-09 21:38 [BUG] Edge case for preview image alignment Karthik Chikmagalur
2025-01-10 18:55 ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).