-
Notifications
You must be signed in to change notification settings - Fork 432
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(i18n): allow simple HTML tags when using Translate component #5114
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
Full Reportsanity
@sanity/types
sanity/desk
@sanity/diff
@sanity/block-tools
@sanity/portable-text-editor
@sanity/mutator
@sanity/cli
@sanity/schema/_internal
@sanity/util/paths
sanity/router
@sanity/util/legacyDateFormat
@sanity/schema
sanity/cli
@sanity/vision
@sanity/util/fs
sanity/_internal
@sanity/util/content
|
Component Testing Report Updated Nov 3, 2023 6:13 PM (UTC)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a question/comment, otherwise great!
) | ||
}) | ||
test('tags cant contain whitespace or special characters', () => { | ||
expect(() => simpleParser('foo <Em@ail> bar</Em@ail>')).toThrow( | ||
'Invalid tag "<Em@ail>". Tag names must start with an uppercase letter and can only include letters and numbers.', | ||
'Invalid tag "<Em@ail>". Tag names must be lowercase HTML tags or start with an uppercase letter and can only include letters and numbers.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we mention the subset of tags we allow here?
|
||
throw new Error( | ||
tagName.trim() === tagName | ||
? `Invalid tag "<${tagName}>". Tag names must be lowercase HTML tags or start with an uppercase letter and can only include letters and numbers.` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re:previous comment: maybe this would be a better place to mention what subset of tags we allow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe. It does print an error in the Translate component, so I think that is fine for now. I tried refactoring, but ran into some parser shenanigan holes that I don't want to reason about at the moment. We can get back to it later if it becomes a problem.
cf327ca
to
f87050f
Compare
Description
It's a bit tedious to pass in components like
<Code>
that just maps to<code>
. This PR allows using this predefined list of tags without specifying it directly:<abbr>
,<address>
,<cite>
,<code>
,<del>
,<em>
,<ins>
,<kbd>
,<q>
,<samp>
,<strong>
,<sub>
,<sup>
.The reason for these specifically is that they are inline elements that do not require any attributes for use, and is not deprecated by the HTML5 spec.
I'm not sure if my solution in the parser was the best, but I didn't want to spend more time finding a more elegant way to approach it - open to suggestions.
What to review
<Translate/>
component works as it shouldNotes for release
None.