Skip to content

Extract RenderedHtml component #3220

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

Merged
merged 3 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/components/rendered-html.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{!--
This component renders raw HTML. Be very careful with this since it
can enable cross-site scripting attacks!
--}}
<div local-class="wrapper" ...attributes {{highlight-syntax selector="pre > code"}}>
{{html-safe @html}}
</div>
38 changes: 38 additions & 0 deletions app/components/rendered-html.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.wrapper {
line-height: 1.5;
overflow-wrap: break-word;

> :first-child {
margin-top: 0;
}

> :last-child {
margin-bottom: 0;
}

img {
max-width: 100%;
}

pre {
overflow-x: auto;
}

p {
code {
background-color: #fff;
padding: 0 2px;
}
}

table {
border-collapse: collapse;
display: block;
overflow-x: auto;

th, td {
border: 1px solid #dfe2e5;
padding: 6px 13px;
}
}
}
34 changes: 4 additions & 30 deletions app/styles/crate/version.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ div.header {
.docs {
@media only screen and (min-width: 890px) {
flex: 7;
padding-right: 40px;
padding-right: 20px;
max-width: 640px;
}
}
Expand Down Expand Up @@ -194,35 +194,9 @@ div.header {
margin-bottom: 40px;
}

.crate-readme {
line-height: 1.5;
overflow-wrap: break-word;

img {
max-width: 100%;
}

pre {
overflow-x: auto;
}

p {
code {
background-color: #fff;
padding: 0 2px;
}
}

table {
border-collapse: collapse;
display: block;
overflow-x: auto;

th, td {
border: 1px solid #dfe2e5;
padding: 6px 13px;
}
}
.readme {
margin-top: 20px;
margin-bottom: 20px;
}

.crate-downloads {
Expand Down
4 changes: 2 additions & 2 deletions app/templates/crate/version.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
{{/if}}
</div>
{{#if this.readme}}
<section local-class="crate-readme" aria-label="Readme" {{highlight-syntax selector="pre > code"}}>
{{html-safe this.readme}}
<section aria-label="Readme">
<RenderedHtml @html={{this.readme}} local-class="readme" />
</section>
{{else}}
{{#if this.crate.description}}
Expand Down