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

Wrap HTMl in markdown code #7447

Closed
wants to merge 1 commit into from
Closed

Wrap HTMl in markdown code #7447

wants to merge 1 commit into from

Conversation

StefanoChiodino
Copy link
Contributor

Summary

I noticed the link tag was being rendered as actual HTML in my application, needs to be escaped!

Related Issues/PRs

n/a

I noticed the link tag was being rendered as actual HTML in my application, needs to be escaped!
Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

Thanks @StefanoChiodino!

I'm not opposed to the ticks around our HTML content, but I'd advise against using our strings directly as markdown as we aren't consuming them that way. For descriptions we only convert the link syntax.

const titleEl = this.dom.find('.lh-audit__title', auditEl);
titleEl.appendChild(this.dom.convertMarkdownCodeSnippets(audit.result.title));
this.dom.find('.lh-audit__description', auditEl)
.appendChild(this.dom.convertMarkdownLinkSnippets(audit.result.description));

this.dom.find('.lh-category-header__title', tmpl).appendChild(
this.dom.convertMarkdownCodeSnippets(category.title));
if (category.description) {
const descEl = this.dom.convertMarkdownLinkSnippets(category.description);
this.dom.find('.lh-category-header__description', tmpl).appendChild(descEl);
}

@StefanoChiodino
Copy link
Contributor Author

@patrickhulce thanks, that's good to know. I've unknowingly been converting descriptions to markdown, and that was the only problem I've found. If this is not the way to go, I'll just encode HTML markup or something :)

@brendankenny
Copy link
Member

looks like we have six uses of backticks in audits' description, all in accessibility (probably written in a flow of writing descriptions, or assuming we support backticks in there the same way we do for titles).

I vote for deferring to a solution for #6945 before committing more to backticks for this. And we probably also need to be more consistent on what subset of markdown features we use since folks are using our strings from the LHR (web.dev is another example) and it's hard to know that sometimes we use ` to make preformatted code but that we're also comfortable using ` to mark cases that would be formatted if we were formatting, but we aren't :)

@StefanoChiodino in the meantime, except for markdown links (in some strings) and backticks (in other strings), all our strings are intended to be plain text, so you should be ok just doing a normal html escape on them to get them to display properly.

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

Successfully merging this pull request may close these issues.

3 participants