Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please implement a simple way to specify image sizes in markdown #21473

Closed
ell1e opened this issue Oct 16, 2022 · 5 comments
Closed

Please implement a simple way to specify image sizes in markdown #21473

ell1e opened this issue Oct 16, 2022 · 5 comments
Labels
type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@ell1e
Copy link

ell1e commented Oct 16, 2022

Feature Description

Please specify a simple way to specify image sizes in markdown. This is needed when using High-DPI images in documentation without making tons of low DPI manually scaled copies which kind of goes against the spirit of easy markdown documentation (which IMHO is to not spend hours in some other programs making a complicated baked altered layouted document, but just writing a simple semantic document with minimal markup and done).

Most common syntax (Pandoc extension):

![](https://try.gitea.io/assets/img/logo.svg){width=200}

![](https://try.gitea.io/assets/img/logo.svg){width=200px height=200px}

It's specified here: https://pandoc.org/MANUAL.html#extension-link_attributes and proposed by CommonMark community members in a discussion here: https://talk.commonmark.org/t/support-for-image-dimensions/148/45

Second most common syntax (found in discussions etc.):

![](https://try.gitea.io/assets/img/logo.svg =200x100} (for width 200px, height 100px)

![](https://try.gitea.io/assets/img/logo.svg =200x} (for width 200px, height unspecified)

![](https://try.gitea.io/assets/img/logo.svg =x100} (for height 100px, width unspecified)

What currently works:

This works on Gitea right now, the above stuff doesn't:

<img src="https://try.gitea.io/assets/img/logo.svg" width=100px/>

(can even be nested into markdown links: [<img src="https://try.gitea.io/assets/img/logo.svg" width=100px/>](https://gitea.io))

How to support it?

I think best would be to support both the most common and 2nd most common way. Could be done as a pre-parser that just looks for images and reformats them to "what currently works" before passing on the reformatted markdown to whatever regular library you use for the rest.

Screenshots

No response

@ell1e ell1e added type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/proposal The new feature has not been accepted yet but needs to be discussed first. labels Oct 16, 2022
@delvh
Copy link
Member

delvh commented Oct 16, 2022

  1. Gitea is the wrong place for this feature request, please open this issue in https://github.com/yuin/goldmark (our markdown parser) instead (if still needed).
  2. Markdown should already have a way to specify image sizes:
    <img src="http://example.xyz" alt="…" width="40" height="1000">.
    That should be handled as intended, but is a bit longer.

@delvh delvh closed this as completed Oct 16, 2022
@ell1e
Copy link
Author

ell1e commented Oct 16, 2022

Thanks, I see, I moved here: yuin/goldmark#331

@ell1e
Copy link
Author

ell1e commented Nov 29, 2022

or what it's worth, GitLab is adding this now: https://gitlab.com/gitlab-org/gitlab/-/issues/15697#note_1188752984

Sadly, in goldmark the request hasn't gotten any reaction. That this is possible via hacky, ugly HTML I already addressed in the opening post - yeah, it "works" but it's pretty hostile to newcomers wanting to jump in and help out the project documentation who are unfamiliar with HTML. That it's longer isn't the problem, the problem is the assumption/requirement that anyone wanting to contribute to the docs needs to be familiar with HTML. HTML is not a naturally quick thing to learn for non-coders who may want to contribute.

@delvh
Copy link
Member

delvh commented Nov 29, 2022

I know, but I also think there is a reason why Markdown chose to include (a subset of ?) HTML for anything advanced:
Why define two differing syntaxes when one isn't equipped for it, and the other is already a "well-defined" standard?
That way, the core remains easy to implement, and only really specific things such as image bounds need HTML.

@ell1e
Copy link
Author

ell1e commented Nov 29, 2022

I mean, Markdown already has everything needed for 99% of projects to never touch HTML - except for image sizes. Hence this issue. Image bounds are not very specific, as soon as you have any higher DPI screenshots you just really need them or all the images will display as way too giant for everyone and make the documentation unreadable. And in the age of phone apps and High-DPI laptop screens, a lot of projects will have High-DPI images simply for their official screenshots, so that's not a rare or particularly specific need.

I think the goal should be that the average, simpler project doesn't need to use inline HTML. And it's already almost there, anyway.

@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

No branches or pull requests

2 participants