From 9f7b8677934425f8eba64aca4a97487e35acdc0b Mon Sep 17 00:00:00 2001 From: Sam Stern Date: Wed, 2 Jun 2021 11:32:43 -0400 Subject: [PATCH] Fix many markdown rendering issues (#59) --- app/src/App.vue | 17 +++++++++++++++++ app/tailwind.config.js | 5 +++++ functions/package-lock.json | 12 ++++++------ functions/package.json | 4 ++-- functions/src/content.ts | 9 +++++---- 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/app/src/App.vue b/app/src/App.vue index 5c5bee8f..1e51401f 100644 --- a/app/src/App.vue +++ b/app/src/App.vue @@ -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; +} diff --git a/app/tailwind.config.js b/app/tailwind.config.js index 784b22e4..05cda6dd 100644 --- a/app/tailwind.config.js +++ b/app/tailwind.config.js @@ -66,6 +66,7 @@ module.exports = { typography: { DEFAULT: { css: { + maxWidth: null, "blockquote p::before": { display: "none", }, @@ -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 }, }, }, diff --git a/functions/package-lock.json b/functions/package-lock.json index 2305b5c8..049add08 100644 --- a/functions/package-lock.json +++ b/functions/package-lock.json @@ -545,9 +545,9 @@ "integrity": "sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==" }, "@types/marked": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@types/marked/-/marked-1.2.2.tgz", - "integrity": "sha512-wLfw1hnuuDYrFz97IzJja0pdVsC0oedtS4QsKH1/inyW9qkLQbXgMUqEQT0MVtUBx3twjWeInUfjQbhBVLECXw==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@types/marked/-/marked-2.0.3.tgz", + "integrity": "sha512-lbhSN1rht/tQ+dSWxawCzGgTfxe9DB31iLgiT1ZVT5lshpam/nyOA1m3tKHRoNPctB2ukSL22JZI5Fr+WI/zYg==", "dev": true }, "@types/mime": { @@ -4165,9 +4165,9 @@ } }, "marked": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/marked/-/marked-1.2.9.tgz", - "integrity": "sha512-H8lIX2SvyitGX+TRdtS06m1jHMijKN/XjfH6Ooii9fvxMlh8QdqBfBDkGUpMWH2kQNrtixjzYUa3SH8ROTgRRw==" + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/marked/-/marked-2.0.7.tgz", + "integrity": "sha512-BJXxkuIfJchcXOJWTT2DOL+yFWifFv2yGYOUzvXg8Qz610QKw+sHCvTMYwA+qWGhlA2uivBezChZ/pBy1tWdkQ==" }, "marked-terminal": { "version": "3.3.0", diff --git a/functions/package.json b/functions/package.json index b280f897..bfc18c40 100644 --- a/functions/package.json +++ b/functions/package.json @@ -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", diff --git a/functions/src/content.ts b/functions/src/content.ts index b6161b51..ebe39493 100644 --- a/functions/src/content.ts +++ b/functions/src/content.ts @@ -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") { @@ -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; @@ -189,7 +191,6 @@ function sanitizeHtml( return res; } - res = res.toLowerCase(); res = urljoin(rawBaseUrl, res); return res; });