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

Support Markdown in Add-on Listing Fields #22956

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

chrstinalin
Copy link
Contributor

@chrstinalin chrstinalin commented Dec 20, 2024

Fixes: mozilla/addons#15145

Description

Replaces HTML syntax support with Markdown support in the description, developer_comments, eula, and privacy_policy fields of Addon. Existing HTML in those fields will remain functional until the field is edited. No new HTML will be functional.

Only the markdown-equivalent of currently allowed HTML attributes are allowed. abbr uses the PHP Markdown Extra syntax.

DevHub:

image
image
image

Frontend:

image
image
image

Testing

New Add-ons

  1. Create a listed add-on.
  2. Under 'submit/details', description should have the tooltip and support markdown.

Existing Add-ons

  1. Navigate to an add-on that already has HTML in its description. The HTML should still be functional. The HTML is still rendered on the frontend listing.
  2. Under the 'edit' page, the description and developer comments should support markdown syntax.*
  3. Under the 'Manage Authors & License' page, the EULA and Privacy Policy fields should support markdown syntax.*

* Any user-inputted HTML saved at this point is rendered as plaintext. Any allowed markdown in the field is rendered as expected in the frontend. Disallowed markdown is stripped from the result and not visible at all (this is to avoid showing the user the markdown formatted into HTML).

Checklist

  • Add #ISSUENUM at the top of your PR to an existing open issue in the mozilla/addons repository.
  • Successfully verified the change locally.
  • The change is covered by automated tests, or otherwise indicated why doing so is unnecessary/impossible.
  • Add before and after screenshots (Only for changes that impact the UI).
  • Add or update relevant docs reflecting the changes made.

@chrstinalin chrstinalin marked this pull request as draft December 20, 2024 21:05
@chrstinalin chrstinalin marked this pull request as ready for review December 24, 2024 17:33
@chrstinalin chrstinalin requested review from a team and KevinMind and removed request for a team December 24, 2024 17:41
@chrstinalin
Copy link
Contributor Author

There should probably be a more informative way to explain what syntax or Markdown is supported, possibly similar to how GitHub explains it via the 'Markdown is Supported' button by navigating to a dedicated page.

Copy link
Contributor

@KevinMind KevinMind left a comment

Choose a reason for hiding this comment

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

Looks promising. A few comments before testing.

src/olympia/translations/models.py Show resolved Hide resolved
src/olympia/devhub/templates/devhub/includes/macros.html Outdated Show resolved Hide resolved
src/olympia/devhub/templates/devhub/includes/macros.html Outdated Show resolved Hide resolved
src/olympia/translations/models.py Show resolved Hide resolved
@KevinMind
Copy link
Contributor

Please add testing steps and I can verify the PR.

@chrstinalin chrstinalin requested a review from KevinMind January 8, 2025 14:39
@KevinMind
Copy link
Contributor

@chrstinalin what should I expect to happen if I enter invalid or disallowed markdown syntax? Can you add that to the test scenario. Additionally can you clarify what "functional" means? I think you mean the syntax should be "rendered" on the page right?

links = doc('a[href="http://external.url"][rel="nofollow"]')
assert links[0].text == 'http://example.com'
assert doc('strong')[0].text == 'markup'

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a test of mixed html and markdown, simulating someone editing an existing html string and adding markdown to it. We would expect the html to be stringified and the markdown to be formatted to html right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

test_markdown does have a case of mixed HTML and markdown, and yeah -- the HTML is stringified, the markdown is formatted.

@chrstinalin chrstinalin requested a review from KevinMind January 9, 2025 16:08
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.

[Task]: Support markdown in add-on listing fields
2 participants