From c8ab6c728d6b5d4d3109a93c1caea956e4986af3 Mon Sep 17 00:00:00 2001 From: Ken Sternberg <133134217+kensternberg-authentik@users.noreply.github.com> Date: Tue, 26 Mar 2024 15:30:20 -0700 Subject: [PATCH] web: fix markdown rendering bug for alerts (#9037) * web: fix esbuild issue with style sheets Getting ESBuild, Lit, and Storybook to all agree on how to read and parse stylesheets is a serious pain. This fix better identifies the value types (instances) being passed from various sources in the repo to the three *different* kinds of style processors we're using (the native one, the polyfill one, and whatever the heck Storybook does internally). Falling back to using older CSS instantiating techniques one era at a time seems to do the trick. It's ugly, but in the face of the aggressive styling we use to avoid Flashes of Unstyled Content (FLoUC), it's the logic with which we're left. In standard mode, the following warning appears on the console when running a Flow: ``` Autofocus processing was blocked because a document already has a focused element. ``` In compatibility mode, the following **error** appears on the console when running a Flow: ``` crawler-inject.js:1106 Uncaught TypeError: Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'Node'. at initDomMutationObservers (crawler-inject.js:1106:18) at crawler-inject.js:1114:24 at Array.forEach () at initDomMutationObservers (crawler-inject.js:1114:10) at crawler-inject.js:1549:1 initDomMutationObservers @ crawler-inject.js:1106 (anonymous) @ crawler-inject.js:1114 initDomMutationObservers @ crawler-inject.js:1114 (anonymous) @ crawler-inject.js:1549 ``` Despite this error, nothing seems to be broken and flows work as anticipated. * web:fix markdown rendering bug for alerts The move to using showdown dynamically, at run-time, resulted in a parse error where our alerts were not being decorated with the right syntax. This patch recognizes the new `:::info` EOL syntax (and leaves the old one in-place, as well) and the rendering is now correct. Our complexity has reached the point where eslint now needs the memory increase. --- web/package.json | 4 ++-- web/src/elements/Markdown.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/package.json b/web/package.json index 60e0c505ad..4f3e5910fd 100644 --- a/web/package.json +++ b/web/package.json @@ -14,8 +14,8 @@ "build": "run-s build-locales esbuild:build", "build-proxy": "run-s build-locales esbuild:build-proxy", "watch": "run-s build-locales esbuild:watch", - "lint": "eslint . --max-warnings 0 --fix", - "lint:precommit": "node scripts/eslint-precommit.mjs", + "lint": "cross-env NODE_OPTIONS='--max_old_space_size=8192' eslint . --max-warnings 0 --fix", + "lint:precommit": "cross-env NODE_OPTIONS='--max_old_space_size=8192' node scripts/eslint-precommit.mjs", "lint:spelling": "node scripts/check-spelling.mjs", "lit-analyse": "lit-analyzer src", "precommit": "npm-run-all --parallel tsc lit-analyse lint:spelling --sequential lint:precommit prettier", diff --git a/web/src/elements/Markdown.ts b/web/src/elements/Markdown.ts index 8471b951e7..4b02040262 100644 --- a/web/src/elements/Markdown.ts +++ b/web/src/elements/Markdown.ts @@ -56,7 +56,7 @@ export class Markdown extends AKElement { converter = new showdown.Converter({ metadata: true, tables: true }); replaceAdmonitions(input: string): string { - const admonitionStart = /:::(\w+)/gm; + const admonitionStart = /:::(\w+)(|\s*$)/gm; const admonitionEnd = /:::/gm; return ( input