From 310fb32e69526184e1109322c2586cd33ba97111 Mon Sep 17 00:00:00 2001 From: CodeShell <122738806+CodeShellDev@users.noreply.github.com> Date: Tue, 18 Nov 2025 20:00:50 +0100 Subject: [PATCH 1/4] remove scalar plugin in favor of prettier --- docusaurus.config.js | 1 - src/theme/prism/custom/prism-yaml-scalar.js | 32 --------------------- 2 files changed, 33 deletions(-) delete mode 100644 src/theme/prism/custom/prism-yaml-scalar.js diff --git a/docusaurus.config.js b/docusaurus.config.js index 209aa9a..45b69d5 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -144,7 +144,6 @@ const config = { additionalLanguages: [ "bash", "apacheconf", - "custom-yaml-scalar", "custom-go-template", "custom-yaml-go-template", "custom-yaml-empty-key", diff --git a/src/theme/prism/custom/prism-yaml-scalar.js b/src/theme/prism/custom/prism-yaml-scalar.js deleted file mode 100644 index 550b91a..0000000 --- a/src/theme/prism/custom/prism-yaml-scalar.js +++ /dev/null @@ -1,32 +0,0 @@ -;(function (Prism) { - // https://yaml.org/spec/1.2/spec.html#c-ns-anchor-property - // https://yaml.org/spec/1.2/spec.html#c-ns-alias-node - var anchorOrAlias = /[*&][^\s[\]{},]+/ - // https://yaml.org/spec/1.2/spec.html#c-ns-tag-property - var tag = - /!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/ - // https://yaml.org/spec/1.2/spec.html#c-ns-properties(n,c) - var properties = - "(?:" + - tag.source + - "(?:[ \t]+" + - anchorOrAlias.source + - ")?|" + - anchorOrAlias.source + - "(?:[ \t]+" + - tag.source + - ")?)" - - globalThis.Prism.languages.yaml["scalar"] = { - pattern: RegExp( - /([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*([\s\S]*?)(?=(\r?\n[\S\-]|$))/.source.replace( - /<>/g, - function () { - return properties - } - ) - ), - lookbehind: true, - alias: "string", - } -})(Prism) From fb919cd89972dff96a523181f8b7e8122b4506fb Mon Sep 17 00:00:00 2001 From: CodeShell <122738806+CodeShellDev@users.noreply.github.com> Date: Tue, 18 Nov 2025 20:01:58 +0100 Subject: [PATCH 2/4] fix message templates --- docs/integrations/authentik/authentik.md | 12 +----------- docs/integrations/authentik/message-template.yml | 3 ++- docs/integrations/gitea/message-template.yml | 7 ++++--- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/docs/integrations/authentik/authentik.md b/docs/integrations/authentik/authentik.md index 42131a2..142fef1 100644 --- a/docs/integrations/authentik/authentik.md +++ b/docs/integrations/authentik/authentik.md @@ -72,17 +72,7 @@ return { Since you have decided to go the advanced way, you will have to use [**Message Templates**](../configuration/message-templates), here is an example: ```yaml -settings: - message: - template: | - **Your Verification Code** - - Use the verification code below to complete your sign-in: - - {{ @token }} - - This code expires in 5 minutes⏱️. - If you didn’t request it, you can ignore this message. +{{{ #://./message-template.yaml }}} ``` ### 4. Enable SMS-Verification diff --git a/docs/integrations/authentik/message-template.yml b/docs/integrations/authentik/message-template.yml index afd47d2..a6750db 100644 --- a/docs/integrations/authentik/message-template.yml +++ b/docs/integrations/authentik/message-template.yml @@ -1,11 +1,12 @@ settings: message: + # prettier-ignore template: | **Your Verification Code** Use the verification code below to complete your sign-in: {{ @token }} - + This code expires in 5 minutes⏱️. If you didn’t request it, you can ignore this message. diff --git a/docs/integrations/gitea/message-template.yml b/docs/integrations/gitea/message-template.yml index f1145f5..1fdaa92 100644 --- a/docs/integrations/gitea/message-template.yml +++ b/docs/integrations/gitea/message-template.yml @@ -1,5 +1,6 @@ settings: message: + # prettier-ignore template: | {{- /* === ISSUE === */ - }} {{- if and @issue (ne @issue nil) (not @is_pull) -}} @@ -7,14 +8,14 @@ settings: {{ if eq @issue.state "open" -}}🟢{{- else if eq @issue.state "closed" -}}🔴{{- else -}}{{@issue.state}}{{- end }} | 👤 {{@sender.full_name}} 🔗 {{@issue.html_url}} {{- end -}} - + {{- /* === PULL REQUEST === */ - }} {{- if and @pull_request (ne @pull_request nil) -}} 🚀 **#{{@pull_request.number}} {{@pull_request.title}}** {{ if eq @pull_request.state "open" -}}🟢{{- else if eq @pull_request.state "closed" -}}🔴{{- else if eq @pull_request.state "merged" -}}🟣{{- else -}}{{@pull_request.state}}{{- end }} | 👤 {{@sender.full_name}} 🔗 {{@pull_request.html_url}} {{- end -}} - + {{- /* === COMMIT === */ - }} {{- if and @commits (gt (len @commits) 0) }} 📥️ **Push** → *{{@ref}}* @@ -32,6 +33,6 @@ settings: {{- end }} 🔗 {{.url}} {{- end }} - + 🔎 Compare: {{@compare_url}} {{- end -}} From 0f58a57d4baf02a39e4e8023c45d8ae3cb54ff60 Mon Sep 17 00:00:00 2001 From: CodeShell <122738806+CodeShellDev@users.noreply.github.com> Date: Tue, 18 Nov 2025 20:02:19 +0100 Subject: [PATCH 3/4] cleanup in go template plugin --- src/theme/prism/custom/prism-go-template.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/theme/prism/custom/prism-go-template.js b/src/theme/prism/custom/prism-go-template.js index 281adab..5986c9e 100644 --- a/src/theme/prism/custom/prism-go-template.js +++ b/src/theme/prism/custom/prism-go-template.js @@ -9,7 +9,7 @@ const lang = "go-template" alias: "comment", inside: { delimiter: /^\{\{\/\*|\*\/\}\}/, - content: /[\s\S]+/, // the inner comment content + content: /[\s\S]+/, }, }, @@ -20,7 +20,7 @@ const lang = "go-template" alias: "variable", inside: { delimiter: /^\{\{|\}\}$/, - expression: /[\s\S]+/, // the inner expression + expression: /[\s\S]+/, }, }, } From 7723bf08d38c0b3fa8952c1731ea8e1b4da6737b Mon Sep 17 00:00:00 2001 From: CodeShell <122738806+CodeShellDev@users.noreply.github.com> Date: Tue, 18 Nov 2025 20:02:32 +0100 Subject: [PATCH 4/4] add prettier-ignore filter for docusaurus --- docusaurus.config.js | 6 +++++- package-lock.json | 3 ++- package.json | 3 ++- prettier-ignore.js | 15 +++++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 prettier-ignore.js diff --git a/docusaurus.config.js b/docusaurus.config.js index 45b69d5..449b0c5 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -62,7 +62,11 @@ const config = { beforeDefaultRemarkPlugins: [ require("remark-github-admonitions-to-directives"), ], - remarkPlugins: [require("remark-gfm"), require("remark-directive")], + remarkPlugins: [ + require("remark-gfm"), + require("remark-directive"), + require("./prettier-ignore"), + ], }, theme: { customCss: ["./src/css/custom.css"], diff --git a/package-lock.json b/package-lock.json index d78cb47..db9b867 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,8 @@ "react-dom": "^19.0.0", "remark-directive": "^4.0.0", "remark-gfm": "^4.0.1", - "remark-github-admonitions-to-directives": "^2.1.0" + "remark-github-admonitions-to-directives": "^2.1.0", + "unist-util-visit": "^5.0.0" }, "devDependencies": { "@docusaurus/module-type-aliases": "3.9.2", diff --git a/package.json b/package.json index 25ba781..06e3d37 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "react-dom": "^19.0.0", "remark-directive": "^4.0.0", "remark-gfm": "^4.0.1", - "remark-github-admonitions-to-directives": "^2.1.0" + "remark-github-admonitions-to-directives": "^2.1.0", + "unist-util-visit": "^5.0.0" }, "devDependencies": { "@docusaurus/module-type-aliases": "3.9.2", diff --git a/prettier-ignore.js b/prettier-ignore.js new file mode 100644 index 0000000..98d00f2 --- /dev/null +++ b/prettier-ignore.js @@ -0,0 +1,15 @@ +module.exports = () => { + return (tree) => { + const visit = require("unist-util-visit").visit + + visit(tree, "code", (node) => { + if (node.value) { + // Remove any line that contains "# prettier-ignore" + node.value = node.value + .split("\n") + .filter((line) => !line.includes("# prettier-ignore")) + .join("\n") + } + }) + } +}