From 25e04a2ecbda7952a68220ce6739ae1c75144858 Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Mon, 24 Jul 2023 23:36:32 +0000 Subject: [ci] format --- .../src/html/css/parse-inline-css-to-react.ts | 35 +++++++++++----------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'packages/integrations/markdoc/src/html/css/parse-inline-css-to-react.ts') diff --git a/packages/integrations/markdoc/src/html/css/parse-inline-css-to-react.ts b/packages/integrations/markdoc/src/html/css/parse-inline-css-to-react.ts index 3b67f9a32..dd429788a 100644 --- a/packages/integrations/markdoc/src/html/css/parse-inline-css-to-react.ts +++ b/packages/integrations/markdoc/src/html/css/parse-inline-css-to-react.ts @@ -1,23 +1,24 @@ +import { styleToObject } from './style-to-object.js'; -import { styleToObject } from "./style-to-object.js"; +export function parseInlineCSSToReactLikeObject( + css: string | undefined | null +): React.CSSProperties | undefined { + if (typeof css === 'string') { + const cssObject: Record = {}; + styleToObject(css, (originalCssDirective: string, value: string) => { + const reactCssDirective = convertCssDirectiveNameToReactCamelCase(originalCssDirective); + cssObject[reactCssDirective] = value; + }); + return cssObject; + } -export function parseInlineCSSToReactLikeObject(css: string | undefined | null): React.CSSProperties | undefined { - if (typeof css === "string") { - const cssObject: Record = {}; - styleToObject(css, (originalCssDirective: string, value: string) => { - const reactCssDirective = convertCssDirectiveNameToReactCamelCase(originalCssDirective); - cssObject[reactCssDirective] = value; - }); - return cssObject; - } - - return undefined; + return undefined; } function convertCssDirectiveNameToReactCamelCase(original: string): string { - // capture group 1 is the character to capitalize, the hyphen is omitted by virtue of being outside the capture group - const replaced = original.replace(/-([a-z0-9])/ig, (_match, char) => { - return char.toUpperCase(); - }); - return replaced; + // capture group 1 is the character to capitalize, the hyphen is omitted by virtue of being outside the capture group + const replaced = original.replace(/-([a-z0-9])/gi, (_match, char) => { + return char.toUpperCase(); + }); + return replaced; } -- cgit v1.2.3