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

feat(gnoweb): disable html in markdown #2964

Merged
merged 6 commits into from
Oct 20, 2024
Merged

Conversation

alexiscolin
Copy link
Member

@alexiscolin alexiscolin commented Oct 17, 2024

In line with our vision for a HTML-free Gnoweb, this PR disables the rendering of HTML within Markdown content. It replaces all elements recognized as HTML tags (e.g., <div>, <br>, <web-component>) with empty spaces before sending the content to the front-end. The parsing still happens via JavaScript, but now without any HTML tags. However, HTML tags like `<div>lorem ipsum</div>` can still appear within code blocks in Markdown, as usual, but won’t be parsed/read as actual HTML.

Additionally, this feature is controlled by the gnoweb boolean flag with-html, which defaults to false.

cc @gfanton

Warning

Enabling this feature will break the design of gno.land realms (and any other realms relying on HTML), since current layout elements like columns, stacks, or jumbotrons... are built with HTML. We will need to adopt the new design system expected with gnoweb2.0 (or future gnoweb1 improvements).

BEFORE:

127 0 0 1_8888_ (1)

AFTER:

127 0 0 1_8888_ (2)


BEFORE:

127 0 0 1_8888_r_gnoland_pages

AFTER:

127 0 0 1_8888_r_gnoland_pages (1)

@github-actions github-actions bot added the 📦 ⛰️ gno.land Issues or PRs gno.land package related label Oct 17, 2024
Copy link

codecov bot commented Oct 17, 2024

Codecov Report

Attention: Patch coverage is 42.85714% with 12 lines in your changes missing coverage. Please review.

Project coverage is 63.07%. Comparing base (f6bd2d3) to head (4aaf19d).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
gno.land/pkg/gnoweb/gnoweb.go 40.00% 9 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2964      +/-   ##
==========================================
- Coverage   63.08%   63.07%   -0.01%     
==========================================
  Files         563      563              
  Lines       79254    79273      +19     
==========================================
+ Hits        49998    50005       +7     
- Misses      25896    25904       +8     
- Partials     3360     3364       +4     
Flag Coverage Δ
contribs/gnodev 60.62% <ø> (ø)
contribs/gnofaucet 15.77% <ø> (+0.94%) ⬆️
gno.land 67.46% <42.85%> (-0.10%) ⬇️
gnovm 67.25% <ø> (ø)
misc/genstd 79.72% <ø> (ø)
misc/logos 19.45% <ø> (ø)
tm2 62.25% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@moul
Copy link
Member

moul commented Oct 17, 2024

This is the way.

gno.land/cmd/gnoweb/main.go Outdated Show resolved Hide resolved
contribs/gnodev/go.mod Show resolved Hide resolved
gno.land/pkg/gnoweb/gnoweb.go Outdated Show resolved Hide resolved
@albttx
Copy link
Member

albttx commented Oct 17, 2024

I just checked my r/albttx/home render, Could you also fix <img alt="desc" src="url" > into ![desc](url),

BEFORE

image

AFTER

image

ps: It's cool that you kept the options with a --with-html flags :)

@alexiscolin alexiscolin reopened this Oct 17, 2024
@alexiscolin
Copy link
Member Author

@albttx Thank you for the additional tests! I really appreciate :)
I understand your point but translating HTML to Markdown would go against our ultimate goal of avoiding HTML in realms. The focus should be on enhancing Markdown itself to handle the use cases where HTML is currently needed, keeping things consistent and avoiding the introduction of HTML into realms. If we fix HTML, we still promote it in a way.

gno.land/pkg/gnoweb/gnoweb.go Outdated Show resolved Hide resolved
gno.land/pkg/gnoweb/gnoweb.go Outdated Show resolved Hide resolved
gno.land/pkg/gnoweb/gnoweb.go Outdated Show resolved Hide resolved
@moul moul merged commit 93ece90 into gnolang:master Oct 20, 2024
120 of 122 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 ⛰️ gno.land Issues or PRs gno.land package related
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants