Repository navigation
feat(editor): read image size and alignment from the alt - #198
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #194.
An image that is alone on its line now takes its size and alignment from the alt text, the form Obsidian uses:
Other renderers either honour it or show the image at its natural size, so the file stays valid Markdown. The options are marked as syntax, so they shrink like the brackets and are revealed on the cursor line.
What changed:
markdown_render:ImageOptions,parse_alt_options,with_alt_optionsandrewrite_image_alt.Ornament::ImageandImageRefcarry the options, and the alt they expose is already clean.markdown_view:image_boxdecides the painted size and the gap. It honours the requested width and height, never goes wider than the column, and is capped at 900 px of height. Without a size nothing is enlarged, and the gap now fits the image instead of always reserving 150 px.editor: the gap tag is applied per image height through the existing tag cache, and the right-click menu on an image offers Small, Medium, Large, Original size and the three alignments. Only the alt is rewritten, never the destination or the title.Tests: unit tests for the parser, the rewriter and the geometry, plus
tests/image_size.rswith a real texture, the measured gap, and the three menu actions.make checkgreen. The Xvfb check shows a 480 px image next to a 216 px one with no size, and the menu writes|240when Small is picked.