Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Codidact Meta!

Codidact Meta is the meta-discussion site for the Codidact community network and the Codidact software. Whether you have bug reports or feature requests, support questions or rule discussions that touch the whole network – this is the site for you.

Comments on Although div tag is not allowed, it's rendered in the preview

Post

Although div tag is not allowed, it's rendered in the preview

+8
−0

tl;dr

According to this post, the div tag is not allowed, thus it's removed from posts. But it's not removed from the preview, and I believe both (the preview and the final saved post) should be consistent between each other.


I've made this test on the dev server, using HTML that contains a div.

In the post editor, I've used this HTML:

<div dir="rtl">abc...</div>

I'm using dir="rtl" because it gives a good visual hint that the div is there, as we can see in the images below.


In the preview, the div is rendered:

div is rendered in the preview

We can see the div is there in the preview, by checking the browser's console, and also by noting that dir="rtl" was applied (text is using right-to-left direction).


But when I save the post, the div is removed:

div is removed from the saved post

We can see that by checking the browser's console, and also noting that right-to-left is no longer being applied (which confirms that the tag was removed).


This is not a feature request to add support for div. It's a bug report about the inconsistency between the preview and the final rendered post. If a tag is removed from the saved post, the preview should remove it as well.

I believe that both should render everything the same way, whenever it's possible. This would avoid situations where an user thinks their HTML will work, but will find out it doesn't work only after saving the post.


One interesting detail: if you try to edit the test post in dev server, you'll notice that the div is still there. So it wasn't actually removed from the markdown text, it's just not rendered in the final HTML.


PS: I've also tested with kbd and the same happens (it's rendered in the preview, and removed after saving the post). I haven't tested with other tags.

History
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

We don't support `div`.. (2 comments)
We don't support `div`..
deleted user wrote over 2 years ago
a p span b i em strong hr h1 h2 h3 h4 h5 h6 blockquote img strike del code pre br ul ol li sup sub section details summary ins table thead tbody tr th td s

We just support above markdown. And following attributes

id class href title src height width alt rowspan colspan lang start dir

Note : It's only for post body not comment.

https://github.com/codidact/qpixel/blob/develop/app/helpers/posts_helper.rb#L21-L23

hkotsubo‭ wrote over 2 years ago

deleted user The first link in the question goes to a page that has this list of tags. Anyway, I'm not asking about that. I know that div is not supported. The problem I'm reporting is that the editor's preview doesn't remove div's, and I believe it should, for the sake of consistency (after saving the post, div is removed, so the preview should remove it too).