From 38cff2d670ecf7fd325aaaf776a4c250a72cc661 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Tue, 04 Jul 2023 23:48:36 +0000
Subject: [PATCH] more visual polish, adjust colours and spacing
---
quartz/plugins/transformers/description.ts | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/quartz/plugins/transformers/description.ts b/quartz/plugins/transformers/description.ts
index 0e41c5b..cc20769 100644
--- a/quartz/plugins/transformers/description.ts
+++ b/quartz/plugins/transformers/description.ts
@@ -10,6 +10,10 @@
descriptionLength: 150
}
+const escapeHTML = (unsafe: string) => {
+ return unsafe.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"').replaceAll("'", ''');
+}
+
export const Description: QuartzTransformerPlugin<Partial<Options> | undefined> = (userOpts) => {
const opts = { ...defaultOptions, ...userOpts }
return {
@@ -19,7 +23,7 @@
() => {
return async (tree: HTMLRoot, file) => {
const frontMatterDescription = file.data.frontmatter?.description
- const text = toString(tree)
+ const text = escapeHTML(toString(tree))
const desc = frontMatterDescription ?? text
const sentences = desc.replace(/\s+/g, ' ').split('.')
--
Gitblit v1.10.0