From 31e8359ec0dea3e3d097bf3691307f5ec5a7ada7 Mon Sep 17 00:00:00 2001 From: DecDuck Date: Tue, 24 Dec 2024 10:08:27 +1100 Subject: [PATCH] chore(replace md-it): replaced markdown-it with micromark --- package.json | 3 +- pages/admin/library/[id]/index.vue | 5 +-- pages/store/[id]/index.vue | 7 ++- yarn.lock | 72 ++++++++++-------------------- 4 files changed, 30 insertions(+), 57 deletions(-) diff --git a/package.json b/package.json index 1c1d967..4ae3c56 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "fast-fuzzy": "^1.12.0", "file-type-mime": "^0.4.3", "jdenticon": "^3.3.0", - "markdown-it": "^14.1.0", + "micromark": "^4.0.1", "moment": "^2.30.1", "nuxt": "^3.13.2", "prisma": "^6.1.0", @@ -39,7 +39,6 @@ "@tailwindcss/forms": "^0.5.9", "@tailwindcss/typography": "^0.5.15", "@types/bcryptjs": "^2.4.6", - "@types/markdown-it": "^14.1.2", "@types/turndown": "^5.0.5", "@types/uuid": "^10.0.0", "autoprefixer": "^10.4.20", diff --git a/pages/admin/library/[id]/index.vue b/pages/admin/library/[id]/index.vue index 90dce0b..f802b5c 100644 --- a/pages/admin/library/[id]/index.vue +++ b/pages/admin/library/[id]/index.vue @@ -189,7 +189,7 @@ import { InformationCircleIcon } from "@heroicons/vue/20/solid"; import { Bars3Icon, TrashIcon } from "@heroicons/vue/16/solid"; import type { Game, GameVersion } from "@prisma/client"; -import markdownit from "markdown-it"; +import {micromark} from 'micromark'; import UploadFileDialog from "~/components/UploadFileDialog.vue"; definePageMeta({ @@ -209,8 +209,7 @@ const { game: rawGame, unimportedVersions } = await $fetch( ); const game = ref(rawGame); -const md = markdownit(); -const descriptionHTML = md.render(game.value?.mDescription ?? ""); +const descriptionHTML = micromark(game.value?.mDescription ?? ""); async function updateBannerImage(id: string) { if (game.value.mBannerId == id) return; diff --git a/pages/store/[id]/index.vue b/pages/store/[id]/index.vue index 360cb15..68ebdd5 100644 --- a/pages/store/[id]/index.vue +++ b/pages/store/[id]/index.vue @@ -161,7 +161,7 @@ import { PlusIcon } from "@heroicons/vue/20/solid"; import { ArrowTopRightOnSquareIcon } from "@heroicons/vue/24/outline"; import { StarIcon } from "@heroicons/vue/24/solid"; import { Platform, type Game, type GameVersion } from "@prisma/client"; -import MarkdownIt from "markdown-it"; +import {micromark} from 'micromark'; import moment from "moment"; import LinuxLogo from "~/components/icons/LinuxLogo.vue"; import WindowsLogo from "~/components/icons/WindowsLogo.vue"; @@ -176,7 +176,6 @@ const game = await $fetch( `/api/v1/games/${gameId}`, { headers } ); -const md = MarkdownIt(); // Preview description (first 30 lines) const showPreview = ref(true); @@ -197,9 +196,9 @@ const descriptionSplitIndex = gameDescriptionCharacters.findIndex( const previewDescription = gameDescriptionCharacters .slice(0, descriptionSplitIndex + 1) // Slice a character after .join(""); -const previewHTML = md.render(previewDescription); +const previewHTML = micromark(previewDescription); -const descriptionHTML = md.render(game.mDescription); +const descriptionHTML = micromark(game.mDescription); const showReadMore = previewHTML != descriptionHTML; const platforms = game.versions diff --git a/yarn.lock b/yarn.lock index 124ed94..4b34f10 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1413,19 +1413,6 @@ dependencies: "@types/node" "*" -"@types/linkify-it@^5": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@types/linkify-it/-/linkify-it-5.0.0.tgz#21413001973106cda1c3a9b91eedd4ccd5469d76" - integrity sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q== - -"@types/markdown-it@^14.1.2": - version "14.1.2" - resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-14.1.2.tgz#57f2532a0800067d9b934f3521429a2e8bfb4c61" - integrity sha512-promo4eFwuiW+TfGxhi+0x3czqTYJkG8qB17ZUJiVF10Xm7NLVRSLUsfRTU/6h1e24VvRnXCx+hG7li58lkzog== - dependencies: - "@types/linkify-it" "^5" - "@types/mdurl" "^2" - "@types/mdast@^4.0.0", "@types/mdast@^4.0.3", "@types/mdast@^4.0.4": version "4.0.4" resolved "https://registry.yarnpkg.com/@types/mdast/-/mdast-4.0.4.tgz#7ccf72edd2f1aa7dd3437e180c64373585804dd6" @@ -1433,11 +1420,6 @@ dependencies: "@types/unist" "*" -"@types/mdurl@^2": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@types/mdurl/-/mdurl-2.0.0.tgz#d43878b5b20222682163ae6f897b20447233bdfd" - integrity sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg== - "@types/ms@*": version "0.7.34" resolved "https://registry.yarnpkg.com/@types/ms/-/ms-0.7.34.tgz#10964ba0dee6ac4cd462e2795b6bebd407303433" @@ -2755,7 +2737,7 @@ enhanced-resolve@^5.14.1: graceful-fs "^4.2.4" tapable "^2.2.0" -entities@^4.2.0, entities@^4.4.0, entities@^4.5.0: +entities@^4.2.0, entities@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/entities/-/entities-4.5.0.tgz#5d268ea5e7113ec74c4d033b79ea5a35a488fb48" integrity sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw== @@ -3805,13 +3787,6 @@ lines-and-columns@^1.1.6: resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== -linkify-it@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-5.0.0.tgz#9ef238bfa6dc70bd8e7f9572b52d369af569b421" - integrity sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ== - dependencies: - uc.micro "^2.0.0" - listhen@^1.9.0: version "1.9.0" resolved "https://registry.yarnpkg.com/listhen/-/listhen-1.9.0.tgz#59355f7e4fc1eefda6bc494ae7e9ed13aa7658ef" @@ -3936,18 +3911,6 @@ make-dir@^3.1.0: dependencies: semver "^6.0.0" -markdown-it@^14.1.0: - version "14.1.0" - resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-14.1.0.tgz#3c3c5992883c633db4714ccb4d7b5935d98b7d45" - integrity sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg== - dependencies: - argparse "^2.0.1" - entities "^4.4.0" - linkify-it "^5.0.0" - mdurl "^2.0.0" - punycode.js "^2.3.1" - uc.micro "^2.1.0" - markdown-table@^3.0.0: version "3.0.4" resolved "https://registry.yarnpkg.com/markdown-table/-/markdown-table-3.0.4.tgz#fe44d6d410ff9d6f2ea1797a3f60aa4d2b631c2a" @@ -4389,6 +4352,29 @@ micromark@^4.0.0: micromark-util-symbol "^2.0.0" micromark-util-types "^2.0.0" +micromark@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/micromark/-/micromark-4.0.1.tgz#294c2f12364759e5f9e925a767ae3dfde72223ff" + integrity sha512-eBPdkcoCNvYcxQOAKAlceo5SNdzZWfF+FcSupREAzdAh9rRmE239CEQAiTwIgblwnoM8zzj35sZ5ZwvSEOF6Kw== + dependencies: + "@types/debug" "^4.0.0" + debug "^4.0.0" + decode-named-character-reference "^1.0.0" + devlop "^1.0.0" + micromark-core-commonmark "^2.0.0" + micromark-factory-space "^2.0.0" + micromark-util-character "^2.0.0" + micromark-util-chunked "^2.0.0" + micromark-util-combine-extensions "^2.0.0" + micromark-util-decode-numeric-character-reference "^2.0.0" + micromark-util-encode "^2.0.0" + micromark-util-normalize-identifier "^2.0.0" + micromark-util-resolve-all "^2.0.0" + micromark-util-sanitize-uri "^2.0.0" + micromark-util-subtokenize "^2.0.0" + micromark-util-symbol "^2.0.0" + micromark-util-types "^2.0.0" + micromatch@^4.0.4, micromatch@^4.0.5, micromatch@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202" @@ -5359,11 +5345,6 @@ proxy-from-env@^1.1.0: resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== -punycode.js@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/punycode.js/-/punycode.js-2.3.1.tgz#6b53e56ad75588234e79f4affa90972c7dd8cdb7" - integrity sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA== - queue-microtask@^1.2.2: version "1.2.3" resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" @@ -6318,11 +6299,6 @@ type-fest@^4.18.2, type-fest@^4.7.1: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-4.26.1.tgz#a4a17fa314f976dd3e6d6675ef6c775c16d7955e" integrity sha512-yOGpmOAL7CkKe/91I5O3gPICmJNLJ1G4zFYVAsRHg7M64biSnPtRj0WNQt++bRkjYOqjWXrhnUw1utzmVErAdg== -uc.micro@^2.0.0, uc.micro@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-2.1.0.tgz#f8d3f7d0ec4c3dea35a7e3c8efa4cb8b45c9e7ee" - integrity sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A== - ufo@^1.1.2, ufo@^1.5.4: version "1.5.4" resolved "https://registry.yarnpkg.com/ufo/-/ufo-1.5.4.tgz#16d6949674ca0c9e0fbbae1fa20a71d7b1ded754"