{"version":3,"sources":["../src/parser.ts","../src/utils.ts","../src/styles.ts","../src/parseMarkdownToJSX.ts","../src/components/emailMarkdown.tsx"],"sourcesContent":["import { marked, Renderer } from \"marked\";\nimport { StylesType } from \"./types\";\nimport { initRenderer } from \"./utils\";\n\nexport class MarkdownParser {\n private readonly renderer: Renderer;\n\n constructor({ customStyles }: { customStyles?: StylesType }) {\n this.renderer = initRenderer({ customStyles });\n }\n\n parse(markdown: string) {\n return marked.parse(markdown, { renderer: this.renderer });\n }\n}\n","import { CSSProperties } from \"react\";\nimport { StylesType, initRendererProps } from \"./types\";\nimport { Renderer } from \"marked\";\nimport { styles } from \"./styles\";\n\nfunction escapeQuotes(value: unknown) {\n if (typeof value === 'string' && value.includes('\"')) {\n return value.replace(/\"/g, \"'\");\n }\n return value;\n}\n\nexport function camelToKebabCase(str: string): string {\n return str.replace(/([a-z0-9])([A-Z])/g, \"$1-$2\").toLowerCase();\n}\n\nexport function parseCssInJsToInlineCss(\n cssProperties: CSSProperties | undefined\n): string {\n if (!cssProperties) return \"\";\n\n const numericalCssProperties = [\n \"width\",\n \"height\",\n \"margin\",\n \"marginTop\",\n \"marginRight\",\n \"marginBottom\",\n \"marginLeft\",\n \"padding\",\n \"paddingTop\",\n \"paddingRight\",\n \"paddingBottom\",\n \"paddingLeft\",\n \"borderWidth\",\n \"borderTopWidth\",\n \"borderRightWidth\",\n \"borderBottomWidth\",\n \"borderLeftWidth\",\n \"outlineWidth\",\n \"top\",\n \"right\",\n \"bottom\",\n \"left\",\n \"fontSize\",\n \"lineHeight\",\n \"letterSpacing\",\n \"wordSpacing\",\n \"maxWidth\",\n \"minWidth\",\n \"maxHeight\",\n \"minHeight\",\n \"borderRadius\",\n \"borderTopLeftRadius\",\n \"borderTopRightRadius\",\n \"borderBottomLeftRadius\",\n \"borderBottomRightRadius\",\n \"textIndent\",\n \"gridColumnGap\",\n \"gridRowGap\",\n \"gridGap\",\n \"translateX\",\n \"translateY\",\n ];\n\n return Object.entries(cssProperties)\n .map(([property, value]) => {\n if (\n typeof value === \"number\" &&\n numericalCssProperties.includes(property)\n ) {\n return `${camelToKebabCase(property)}:${value}px`;\n } else {\n const escapedValue = escapeQuotes(value);\n return `${camelToKebabCase(property)}:${escapedValue}`;\n }\n })\n .join(\";\");\n}\n\nexport const initRenderer = ({\n customStyles,\n}: initRendererProps): Renderer => {\n const finalStyles = { ...styles, ...customStyles };\n\n const customRenderer = new Renderer();\n\n customRenderer.blockquote = (quote) => {\n return `
\\n${quote}\\n`;\n }\n\n customRenderer.br = () => {\n return `
${code}\\n`;\n }\n\n customRenderer.codespan = (text) => {\n return `${text}`;\n }\n\n customRenderer.del = (text) => {\n return `${text}
\\n`;\n }\n\n customRenderer.strong = (text) => {\n return `${text}`;\n }\n\n customRenderer.table = (header, body) => {\n if (body) body = `${body}`;\n\n return `