Skip to content

Commit

Permalink
web/admin: fix markdown table rendering (#8908)
Browse files Browse the repository at this point in the history
* 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 (<anonymous>)
    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 table rendering

"Render Markdown Tables" is not on by default in `snowdown`; this
commit activates it.  In a "You touched it, now you have to fix it"
moment, Sonar has me fixing a little lint along the way.
  • Loading branch information
kensternberg-authentik authored Mar 14, 2024
1 parent be1219a commit 7720480
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions web/src/elements/Markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class Markdown extends AKElement {
];
}

converter = new showdown.Converter({ metadata: true });
converter = new showdown.Converter({ metadata: true, tables: true });

replaceAdmonitions(input: string): string {
const admonitionStart = /:::(\w+)<br\s\/>/gm;
Expand All @@ -74,13 +74,12 @@ export class Markdown extends AKElement {
replaceRelativeLinks(input: string, md: MarkdownDocument): string {
const baseName = md.path.replace(isFile, "");
const baseUrl = docLink("");
const result = input.replace(isRelativeLink, (match, path) => {
return input.replace(isRelativeLink, (_match, path) => {
const pathName = path.replace(".md", "");
const link = `docs/${baseName}${pathName}`;
const url = new URL(link, baseUrl).toString();
return `href="${url}" _target="blank"`;
});
return result;
}

willUpdate(properties: PropertyValues<this>) {
Expand Down

0 comments on commit 7720480

Please sign in to comment.