Skip to content

fix(markdown): preserve image URL in citation conversion#1994

Open
devteamaegis wants to merge 1 commit into
unclecode:mainfrom
devteamaegis:fix/preserve-image-url-in-citations
Open

fix(markdown): preserve image URL in citation conversion#1994
devteamaegis wants to merge 1 commit into
unclecode:mainfrom
devteamaegis:fix/preserve-image-url-in-citations

Conversation

@devteamaegis
Copy link
Copy Markdown

Bug

DefaultMarkdownGenerator.convert_links_to_citations converts ![alt](url) image links to ![alt⟨n⟩] — dropping the (url) part. This is invalid Markdown: images without a URL render as broken empty brackets rather than the actual image.

Before (broken):

Input:  ![Logo](https://example.com/logo.png)
Output: ![Logo⟨1⟩]        ← no URL → broken image

After (fixed):

Input:  ![Logo](https://example.com/logo.png)
Output: ![Logo⟨1⟩](https://example.com/logo.png)  ← image renders + citation number

Root cause

The citation conversion for images only rebuilt the ![text⟨n⟩] part without the trailing (url):

# Before
else f"![{text}{num}⟩]"

Regular hyperlinks [text](url)text⟨n⟩ correctly omit the URL (it goes to the References section). But images need their URL kept inline because:

  1. Markdown does not support reference-style images in all renderers.
  2. The visual image must remain intact — users can't "look up" an image by citation number.

Fix

One-character change: add ({url}) back to the image output:

# After
else f"![{text}{num}⟩]({url})"

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.

1 participant