Skip to content

fix media description render for orgmode #26895

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

Merged
merged 7 commits into from
Sep 13, 2023

Conversation

earl-warren
Copy link
Contributor

(cherry picked from commit 8b8aab83113b34bade61964e2097ed497abc39e9)

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 4, 2023
Comment on lines +162 to +165
description := strings.TrimPrefix(org.String(l.Description...), "file:")
imageSrc := getMediaURL([]byte(description))
fmt.Fprintf(r, `<a href="%s"><img src="%s" alt="%s" /></a>`, link, imageSrc, imageSrc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thoroughly confused by these changes.
I'd interpret description as alt or title attribute or something like that (which is already present).
But not as an external link that wraps the image.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are from the "official" org package. org/html_writer.go#L406-L427

I would prefer to leave a comment there to tell readers why the code is written as this, where they are copied from.

- In org mode you can specify an description for media via the following
syntax `[[description][media link]]`. The description is then used as
title or alt.
- This patch fixes the rendering of the description by seperating the
description and non-description cases and using `org.String()`.
- Added unit tests.
- Inspired by https://github.com/niklasfasching/go-org/blob/6eb20dbda93cb88c3503f7508dc78cbbc639378f/org/html_writer.go#L406-L427
- Resolves https://codeberg.org/Codeberg/Community/issues/848

(cherry picked from commit 8b8aab83113b34bade61964e2097ed497abc39e9)
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Sep 11, 2023
@lunny lunny added the type/enhancement An improvement of existing functionality label Sep 11, 2023
@lunny lunny added this to the 1.21.0 milestone Sep 11, 2023
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Sep 13, 2023
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Sep 13, 2023
@lunny lunny enabled auto-merge (squash) September 13, 2023 05:05
@lunny lunny merged commit 79afd28 into go-gitea:main Sep 13, 2023
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Sep 13, 2023
zjjhot added a commit to zjjhot/gitea that referenced this pull request Sep 13, 2023
* giteaofficial/main:
  fix media description render for orgmode (go-gitea#26895)
  Show OpenID Connect and OAuth on signup page (go-gitea#20242)
  Update status and code index after changing the default branch (go-gitea#27018)
  add sparse url in cargo package guide (go-gitea#26937)
  Add missing 404 response to Swagger (go-gitea#27038)
  Fix object storage path handling (go-gitea#27024)
  [skip ci] Updated translations via Crowdin
  bump rootful to 16gb
  setup go in the nightly release pipeline
  Speed up nightly builds (go-gitea#27045)
  Improve repo/user/org search  (go-gitea#27030)
  Use Actuated.dev runner for nightly builds
  update snap package (go-gitea#27021)
  resolve issue with sort icons on admin/users and admin/runners (go-gitea#24360)
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Dec 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants