Skip to content

Commit

Permalink
Fix many markdown rendering issues (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
samtstern committed Jun 2, 2021
1 parent 194a08e commit 9f7b867
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 12 deletions.
17 changes: 17 additions & 0 deletions app/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,21 @@ a {
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
}
.prose table {
width: max-content;
}
.prose table td,
.prose table th {
@apply px-2 py-1;
border: 1px solid rgba(0, 0, 0, 0.1);
}
.prose .li-task::before {
display: none;
}
.prose ul li.li-task *:first-child {
margin-right: 4px;
margin-top: 0;
margin-bottom: 0;
}
</style>
5 changes: 5 additions & 0 deletions app/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ module.exports = {
typography: {
DEFAULT: {
css: {
maxWidth: null,
"blockquote p::before": {
display: "none",
},
Expand All @@ -75,6 +76,10 @@ module.exports = {
"code::after": {
display: "none",
},
"thead": null,
"thead th": null,
"thead th:first-child": null,
"thead th:last-child": null
},
},
},
Expand Down
12 changes: 6 additions & 6 deletions functions/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
"cheerio": "^1.0.0-rc.5",
"firebase-admin": "^9.2.0",
"firebase-functions": "^3.11.0",
"marked": "^1.2.9",
"marked": "^2.0.7",
"url-join": "^4.0.1"
},
"devDependencies": {
"@octokit/types": "^6.8.2",
"@types/cheerio": "^0.22.23",
"@types/marked": "^1.2.2",
"@types/marked": "^2.0.3",
"@types/url-join": "^4.0.0",
"concurrently": "^5.3.0",
"firebase-functions-test": "^0.2.0",
Expand Down
9 changes: 5 additions & 4 deletions functions/src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ function sanitizeHtml(
$(el).addClass("prettyprint");
});

// Fix checkbox lists by adding 'li-task' class to target
$('li > input[type="checkbox"]').each((_: number, el: cheerio.Element) => {
$(el).parent().addClass("li-task");
});

// Resolve all relative links to github
$("a").each((_: number, el: cheerio.Element) => {
if (el.type === "text") {
Expand Down Expand Up @@ -174,9 +179,6 @@ function sanitizeHtml(
$(el).addClass("hidden");
}

// Add the image-parent class to the parent
$(el).parent().addClass("img-parent");

// If the image link is relative, make sure it's pointing to GH
modifyAttr(el, "src", (s) => {
let res = s;
Expand All @@ -189,7 +191,6 @@ function sanitizeHtml(
return res;
}

res = res.toLowerCase();
res = urljoin(rawBaseUrl, res);
return res;
});
Expand Down

0 comments on commit 9f7b867

Please sign in to comment.