#54698 closed enhancement (fixed)
Add 'ruby' tag and its friends to kses
Reported by: | upsuper | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 6.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Formatting | Keywords: | has-patch commit add-to-field-guide |
Focuses: | Cc: |
Description
<ruby>
element and its friends are used to attach annotation text onto a piece of text, like
It is especially commonly used in Japanese content, but it can also been seen on content of other languages like Chinese.
The set of elements to enable such functionality consists of <ruby>
, <rt>
, and <rp>
in the HTML Standard, while some browsers (like Firefox) also supports additional ones <rb>
and <rtc>
for more advanced formatting, which are not yet included in the official HTML spec, but can be found in a W3C extension.
These elements are purely presentational, and don't have any special functionality, and thus should not have any security implications for being added to $allowedposttags
. Actually it seems that wordpress.com already supports them, while a local build doesn't.
Attachments (2)
Change History (13)
This ticket was mentioned in PR #2086 on WordPress/wordpress-develop by upsuper.
3 years ago
#1
- Keywords has-patch added
#3
follow-up:
↓ 4
@
3 years ago
Hi there!
Thanks for the ticket and patch.
I updated the patch 54698.patch with parent-child elements hierarchy because <ruby>
is the main parent for all the other elements.
For example:
<ruby><rb>base<rt>annotation</ruby>
<ruby> <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang=fr><rt>Cœur</rt></rtc> <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang=fr><rt>Trèfle</rt></rtc> <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang=fr><rt>Étoile</rt></rtc> </ruby>
#4
in reply to:
↑ 3
;
follow-up:
↓ 7
@
3 years ago
Replying to mukesh27:
I updated the patch 54698.patch with parent-child elements hierarchy because
<ruby>
is the main parent for all the other elements.
Indeed that <ruby>
is the ancestor for all the other elements, but I'm confused by your patch. It seems to me that the second level of arrays are for attributes of the tag, not possible child tags, and <table>
which has a similar structure as <ruby>
doesn't contain any such child element either. If the same idea holds, <table>
should include <caption>
, <tbody>
, <thead>
, <tfoot>
, <tr>
, <td>
, <th>
, <colgroup>
, <col>
. Also, <summary>
can only meaningfully be inside <details>
, and <li>
only in <ol>
and <ul>
, <track>
only in <video>
and <audio>
, etc. But none of them seems to be listed in the way your patch shows.
Could you clarify?
#7
in reply to:
↑ 4
@
3 years ago
- Keywords commit added
Replying to upsuper:
Indeed that
<ruby>
is the ancestor for all the other elements, but I'm confused by your patch. It seems to me that the second level of arrays are for attributes of the tag, not possible child tags, and<table>
which has a similar structure as<ruby>
doesn't contain any such child element either.
You're right, the first PR here appears to be correct as is.
54698.diff adds a unit test. This can be committed after #54699, as the test relies on the changes from that ticket.
The set of elements to enable such functionality consists of
<ruby>
,<rt>
, and<rp>
in the HTML Standard, while some browsers (like Firefox) also supports additional ones<rb>
and<rtc>
for more advanced formatting, which are not yet included in the official HTML spec, but can be found in a W3C extension.
I'm not 100% sure we should add elements that are not in the official HTML spec, but don't see any harm in adding the <rb>
and <rtc>
tags either. If anyone has strong feelings either way, please comment :)
SergeyBiryukov commented on PR #2086:
3 years ago
#9
Thanks for the PR! Merged in https://core.trac.wordpress.org/changeset/52969.
This PR adds the several tags related to ruby text to kses, so that they can be used without
unfiltered_html
rights in post content.Trac ticket: https://core.trac.wordpress.org/ticket/54698