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 HTML tags in markdown #498

Closed
Aloso opened this issue Nov 19, 2021 · 6 comments
Closed

Support HTML tags in markdown #498

Aloso opened this issue Nov 19, 2021 · 6 comments

Comments

@Aloso
Copy link

Aloso commented Nov 19, 2021

Is your proposal related to a problem?

CommonMark markdown supports HTML tags. Websites usually have an allowlist of accepted tags (here's the list of tags accepted by GitHub). Since Lemmy doesn't follow the CommonMark spec, it doesn't support HTML, but I think it should, since HTML is much more flexible and powerful.

Describe the solution you'd like

Lemmy should allow HTML tags. Ideally, it should also follow the CommonMark spec as much as possible.

Describe alternatives you've considered

None.

Additional context

Official CommonMark website and playground.

@dessalines
Copy link
Member

Our markdown parser supports html but we don't have it turned on. To me it seems pretty dangerous. Do you have a use-case that goes beyond what markdown can do?

@Aloso
Copy link
Author

Aloso commented Nov 19, 2021

It's not dangerous if only some html tags and attributes are allowed.

Do you have a use-case that goes beyond what markdown can do?

Yes. The most common use case is a table with line breaks or horizontal lines:

This is a table
with a line break.

HTML also allows you to create a table without a header:

A tablewithout a header

Table cells spanning multiple columns or rows:

Col 1Col 2Col 3Col 4
3 columns2 rows
2 columnssingle

Table captions:

Monthly savings
Month Savings
January $100

Image width set to 25%:

Meta

Image captions:

Meta

Fig. 1: The Meta logo

Description lists:

Coffee
Black hot drink
Milk
White cold drink

Hover titles:

Hover me

Alignment:

I'm far-right!
I'm in the middle!

@Aloso
Copy link
Author

Aloso commented Nov 19, 2021

@dessalines
Copy link
Member

We wouldn't have to do this, it's done by our front end markdown parser: https://github.com/markdown-it/markdown-it

Its fairly sure its safe to turn it on, its a good library.

@dessalines dessalines transferred this issue from LemmyNet/lemmy Nov 19, 2021
@Nutomic
Copy link
Member

Nutomic commented Nov 19, 2021

It would also have to be enabled on the backend for RSS and federation.

@dessalines
Copy link
Member

I don't know that anything would be required for comrak. It doesn't actually render that html and would probably leave it alone when running markdown_to_html.

dessalines added a commit that referenced this issue Nov 22, 2021
Enabling html tags in markdown. Fixes #498
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

No branches or pull requests

3 participants