From 0cdd4224d4a96195275889e952e787933ac2ea40 Mon Sep 17 00:00:00 2001 From: TrebledJ <39648915+TrebledJ@users.noreply.github.com> Date: Sun, 1 Dec 2024 23:15:18 +0800 Subject: [PATCH] chore: copyedit --- .../prism-plugins-in-node/2024-11-03-prism-plugins-in-node.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/posts/programming/mini-projects/prism-plugins-in-node/2024-11-03-prism-plugins-in-node.md b/content/posts/programming/mini-projects/prism-plugins-in-node/2024-11-03-prism-plugins-in-node.md index 9ee0fffdd..4274561d2 100644 --- a/content/posts/programming/mini-projects/prism-plugins-in-node/2024-11-03-prism-plugins-in-node.md +++ b/content/posts/programming/mini-projects/prism-plugins-in-node/2024-11-03-prism-plugins-in-node.md @@ -12,7 +12,7 @@ thumbnail_src: assets/thumbnail.jpg With over 7 million weekly downloads on NPM, PrismJS is one of the most widely used code highlighting packages in JavaScript, lauded for its unparalleled extensibility through plugins. But one recurring issue plagues developers: most plugins require a {% abbr "DOM", "document object model, responsible for managing the UI you see in your wonderful browser" %}! Fancy plugins such as `command-line`, `line-numbers`, and the toolbar suite require a DOM to manipulate HTML. This isn't normally possible in runtime environments such as Node, which aren't designed to render UIs, hence, no DOM. -In this post, I’ll demonstrate a few simple changes to easily coerce these plugins into compatibility with NodeJS and MarkdownIt, a popular markdown renderer.^[One workaround is to use regex to modify HTML — but let’s face it, I sleep more soundly knowing the current implementation is mature and battle-tested. By introducing a DOM API to Node, you're placing trust in a library to be spec-compliant. By handwriting regex, you're placing trust in your code to work. Which would you rather have?] +In this post, I’ll demonstrate a few simple changes to easily coerce these plugins into compatibility with NodeJS and MarkdownIt, a popular markdown renderer.^[Instead of monkeypatching the environment (and potentially affecting other libraries), we could also just write new code using regex to modify HTML, removing the requirement for a DOM altogether. But let’s face it, I sleep more soundly knowing the current implementation is mature and battle-tested. By introducing a DOM API to Node, you're placing trust in a library to be spec-compliant. By handwriting regex, you're placing trust in your code (and regex!) to work. Which would you rather have?] ## Why enhance codeblocks?