diff --git a/components/JsonToHtml/renderOptions.tsx b/components/JsonToHtml/renderOptions.tsx
index 5b4eda0d7..ce7a325b5 100644
--- a/components/JsonToHtml/renderOptions.tsx
+++ b/components/JsonToHtml/renderOptions.tsx
@@ -12,7 +12,11 @@ import Caption from "../TempDesignSystem/Text/Caption"
import Footnote from "../TempDesignSystem/Text/Footnote"
import Subtitle from "../TempDesignSystem/Text/Subtitle"
import Title from "../TempDesignSystem/Text/Title"
-import { hasAvailableParagraphFormat, hasAvailableULFormat } from "./utils"
+import {
+ hasAvailableParagraphFormat,
+ hasAvailableULFormat,
+ makeCssModuleCompatibleClassName,
+} from "./utils"
import styles from "./jsontohtml.module.css"
@@ -217,8 +221,16 @@ export const renderOptions: RenderOptions = {
fullRenderOptions: RenderOptions
) => {
const props = extractPossibleAttributes(node.attrs)
+ const compatibleClassName = makeCssModuleCompatibleClassName(
+ props.className,
+ "ul"
+ )
return (
-
+
{next(node.children, embeds, fullRenderOptions)}
)
@@ -525,17 +537,10 @@ export const renderOptions: RenderOptions = {
fullRenderOptions: RenderOptions
) => {
const props = extractPossibleAttributes(node.attrs)
-
- props.className = props.className || ""
-
- if (props.className) {
- if (hasAvailableULFormat(props.className)) {
- // @ts-ignore: We want to set css modules classNames even if it does not correspond
- // to an existing class in the module style sheet. Due to our css modules plugin for
- // typescript, we cannot do this without the ts-ignore
- props.className = styles[props.className]
- }
- }
+ const compatibleClassName = makeCssModuleCompatibleClassName(
+ props.className,
+ "ul"
+ )
// Set the number of rows dynamically to create even rows for each column. We want the li:s
// to flow with the column, so therefore this is needed.
@@ -549,7 +554,7 @@ export const renderOptions: RenderOptions = {
nodeToHtml(node, embeds, fullRenderOptions))
}
+
+export function makeCssModuleCompatibleClassName(
+ className: string | undefined,
+ formatType: "ul"
+): string {
+ if (!className) return ""
+
+ if (formatType === "ul" && hasAvailableULFormat(className)) {
+ // @ts-ignore: We want to set css modules classNames even if it does not correspond
+ // to an existing class in the module style sheet. Due to our css modules plugin for
+ // typescript, we cannot do this without the ts-ignore
+ return styles[className] || className
+ }
+
+ return className
+}