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

DAH-1865 Handle Apostrophe Character Entity from Salesforce free text fields #2039

Merged
merged 5 commits into from
Dec 22, 2023

Conversation

jimlin-sfgov
Copy link
Collaborator

@jimlin-sfgov jimlin-sfgov commented Dec 19, 2023

@jimlin-sfgov jimlin-sfgov marked this pull request as ready for review December 19, 2023 18:07
@hshaosf hshaosf temporarily deployed to dahlia-webapp-pr-2039 December 19, 2023 18:07 Inactive
@@ -164,14 +164,18 @@ export const getSfGovUrl = (enLink: string, node?: number, path?: string) => {
*/
export function renderMarkup(translatedString: string, allowedTags?: string) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I grepped for the regex renderMarkup\([^t] and found that this function is used for free text fields in some places.

@@ -164,14 +164,18 @@ export const getSfGovUrl = (enLink: string, node?: number, path?: string) => {
*/
export function renderMarkup(translatedString: string, allowedTags?: string) {
return (
<Markdown options={{ forceBlock: true }}>
<Markdown options={{ forceBlock: true, namedCodesToUnicode: { "#39": "\u0027" } }}>
{stripMostTags(translatedString, allowedTags)}
</Markdown>
)
}

export function renderInlineMarkup(translatedString: string, allowedTags?: string) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I grepped for the regex renderInlineMarkup\([^t] and found that this function is used for free text fields in some places.

@jimlin-sfgov jimlin-sfgov force-pushed the DAH-1865-render-salesforce-input-html-entity branch from 0e65082 to fee11a9 Compare December 19, 2023 18:54
@jimlin-sfgov jimlin-sfgov temporarily deployed to dahlia-webapp-pr-2039 December 19, 2023 18:54 Inactive
@@ -25,7 +25,7 @@
"cssnano": "^6.0.1",
"dayjs": "^1.10.7",
"dotenv": "2.0.0",
"markdown-to-jsx": "7.1.8",
"markdown-to-jsx": "7.3.2",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the library because the older version had a bug related to the namedCodesToUnicode option.

@jimlin-sfgov jimlin-sfgov added needs review Pull request needs review and removed WIP labels Dec 19, 2023
@jimlin-sfgov jimlin-sfgov requested a review from a team December 19, 2023 18:55
@jimlin-sfgov jimlin-sfgov temporarily deployed to dahlia-webapp-pr-2039 December 20, 2023 22:23 Inactive
@jimlin-sfgov
Copy link
Collaborator Author

The failing e2e test is the machine translation one, it's not related to the changes made here, and can be safely ignored.

Copy link
Collaborator

@chadbrokaw chadbrokaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question but LGTM

@@ -89,7 +89,9 @@ export const getEventNote = (listingEvent: ListingEvent) => {
<div className="flex flex-col">
{listingEvent.Venue && (
<span className="links-space translate">
<Markdown>{listingEvent.Venue}</Markdown>
<Markdown options={{ namedCodesToUnicode: { "#39": "\u0027" } }}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking: Curious at to why this does not use the renderMarkup function defined below?

question: Should this options object, and the ones below, be extracted into some consts file so that we have better consistency?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious at to why this does not use the renderMarkup function defined below?

I think it should, I've made an update to do that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this options object, and the ones below, be extracted into some consts file so that we have better consistency?

I think we're okay for now, as long as we keep using the renderMarkup functions instead of <Markdown> directly. We may want to revisit this if we need to pass more options to <Markdown>.

@jimlin-sfgov jimlin-sfgov temporarily deployed to dahlia-webapp-pr-2039 December 22, 2023 17:15 Inactive
@jimlin-sfgov jimlin-sfgov merged commit fbde74e into main Dec 22, 2023
13 checks passed
@jimlin-sfgov jimlin-sfgov deleted the DAH-1865-render-salesforce-input-html-entity branch December 22, 2023 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review Pull request needs review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants