From ab9da02c60c962128820e6874e6f07c98bc3dda7 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Tue, 04 Jul 2023 17:08:32 +0000
Subject: [PATCH] fix indexing causing main thread freeze, various polish
---
quartz/plugins/transformers/description.ts | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/quartz/plugins/transformers/description.ts b/quartz/plugins/transformers/description.ts
index ed59f82..cc20769 100644
--- a/quartz/plugins/transformers/description.ts
+++ b/quartz/plugins/transformers/description.ts
@@ -10,19 +10,20 @@
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 {
name: "Description",
- markdownPlugins() {
- return []
- },
htmlPlugins() {
return [
() => {
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