Show inline images in a line's text and for described links !452

merged merged by cmc on 2026-11-22 08:24 UTC · krz/orgstar:issue-113-inline-images into main

Discussion

cmc

Closes #113.

Image links show where org-link-preview-region (Org 9.8.7) previews them, checked against Emacs by an oracle test:

  • A file: or attachment: link without a description, bracket, plain or angle, anywhere in a paragraph, heading, list item, table cell, caption, or quote/center/verse block. Not in verbatim or code text, comments, other keywords, or src/example/export blocks.
  • A link whose description is one file:/attachment: link shows that image in place of the description.
  • Other described links show only with INCLUDE-LINKED. Org does not show them by default or at startup, so this is a second command, Show or Hide Inline Images, Including Described Links (org.toggle-inline-images-linked, C-u C-c C-x C-v), rather than the default the issue assumed. With it, the link's path decides, as in Org.
  • #+ATTR_ORG: :width comes from the link's paragraph.

Layout:

  • A link that is all its line holds is drawn as before.
  • A link in a line's text is hidden, and its first character takes a font as tall as the image and a kern as wide as it, so only that visual line of a wrapped paragraph grows. The fragment draws the image there. On the caret's line the link shows and the images go under the paragraph, side by side.
  • iOS reader: images in a part's text are interpolated into its Text. Links in headings stay links there.

Detection moved from a per-line regex to the syntax tree (InlineImages.links), walked only over the range being styled. Presentation.imagePlacements, imageSize and imageFontSize hold the shared layout decisions.

Tests: swift test green; both Xcode builds succeed. Not checked on screen.