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

invalid jsx generated when using tables with left/right/center alignments #19

Open
darrencruse opened this issue Mar 9, 2017 · 2 comments
Assignees

Comments

@darrencruse
Copy link

darrencruse commented Mar 9, 2017

Hi we have run into an error when using tables in markdown with alignments controlled using the colon syntax e.g.

|     Dropdown Selections    |                          Expanded versions                          |
|:--------------------------:|:-------------------------------------------------------------------:|
|   Automated Variable Rate  |     Automated Variable Rate Irrigation Management Control System    |

In this case the markup generated for the table within the output JSX is like so:

<table>
    <thead>
        <tr>
            <th style="text-align:center">Dropdown Selections</th>
            <th style="text-align:center">Expanded versions</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td style="text-align:center">Automated Variable Rate</td>
            <td style="text-align:center">Automated Variable Rate Irrigation Management Control System</td>
        </tr>
    </tbody>
</table>

And though this would be fine if it were truly html JSX has the requirement that "style" take a bracketed javascript object for the style settings not a simple string. Because of that we're getting this error:

Uncaught Error: The style prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX. This DOM node was rendered by StatelessComponent.
at invariant (bundle.js:14373)
at assertValidProps (bundle.js:158995)
at ReactDOMComponent.mountComponent (bundle.js:159290)
at Object.mountComponent (bundle.js:27293)
at ReactDOMComponent.mountChildren (bundle.js:162536)
at ReactDOMComponent._createInitialChildren (bundle.js:159541)
at ReactDOMComponent.mountComponent (bundle.js:159360)
at Object.mountComponent (bundle.js:27293)
at ReactDOMComponent.mountChildren (bundle.js:162536)
at ReactDOMComponent._createInitialChildren (bundle.js:159541)

Do you think I'm seeing this right? Am I right it seems like a bug with react-markdown-loader?

@darrencruse darrencruse changed the title error when using tables in markdown file invalid jsx generated when using tables with left/right/center alignments Mar 9, 2017
@javiercf
Copy link
Owner

javiercf commented Mar 9, 2017

Hi Darren, thanks for reporting this, yeah it actually looks like we ignored parsing style attributes and converting them to valid jsx, I'll update the module sometime this week as soon as I get some time off from work, if by any chance you guys want to give it a go, it's the function parseCodeBlock located in the parser.js file, thanks for using the module, glad it's helping you guys out!

@javiercf javiercf self-assigned this Mar 9, 2017
@darrencruse
Copy link
Author

thanks fwiw once I understood the problem I decided - heck with the alignment stuff!!

(so actually atm I'm fine just because the table markup I'm generating now without the alignment stuff doesn't have the style="..." part)

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

2 participants