Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline styles are stripped on build #503

Open
jh3y opened this issue Dec 31, 2022 · 0 comments
Open

Inline styles are stripped on build #503

jh3y opened this issue Dec 31, 2022 · 0 comments

Comments

@jh3y
Copy link

jh3y commented Dec 31, 2022

Describe the bug
Tried multiple ways to get around this. I'm using with react-markdown inside of an Astro built site.
The styles run fine in dev but as soon as the site is built, the inline styles are stripped when the highlighter runs. I've even tried a custom renderer.

I know this isn't an Astro thing as I rendered a pre/code combo with spans and inline styles to check it wasn't something getting stripped up above.

Expected behavior
Inline styles don't get stripped when building for production.

** Additional information **
I tried this as a very basic custom renderer to make sure the inline styles were being added.

I didn't want to revert to using a CSS file. But, looks like I'll have to.

const createElement = ({ type, children, ...props }) => {
  if (type === 'text' && props.value) return props.value
  if (children) {
    let style = {}
    for (const s of props.properties.className) style = {...style, ...nightOwl[s]}
    return (
      <span style={style}>
        {children.map(createElement)}    
      </span>
    )
  }
  return null
}

const codeRenderer = ({rows, ...props}) => {
  if (!rows) return <h1>No</h1>
  return (
    <>
      {
        rows.map(createElement)
      }
    </>
  )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant