-
-
Notifications
You must be signed in to change notification settings - Fork 163
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
Whitespace prevents random component to be interpreted #161
Comments
After further investigations, it seems a more global problem: These markdown input render differently: <div class="green">
Hello
</div> <div class ="green">
Hello
</div> <div class= "green">
Hello
</div> <div class = "green">
Hello
</div> if this is parsed using regex, would it be possible to add something like: / *= */ if yes, I'd be glad to help |
Got into the code and found these bits:
and
Should be where the planets align together. /([-A-Z0-9_:]+)\s*=\s*(?:"([^"]+)"|'([^']+)'|\{([^{]+)\})/gi where 4 groups can be extracted: attribute key, double quoted value, single quoted value and curly brackets enclosed value. Then What do you think ? |
Submitted PR in a very lightweight fashion (by just trimming down spaces before parsing) + corresponding tests :) |
Released as 6.5.1, thanks for your contribution! |
Say my render logic is like this:
MyComponent
being as simple as possible like:Now, the problem occurs depending on the markdown input syntax. Observe those two similar inputs:
Input 1 (equal sign with spaces):
Input 2 (equal sign withOUT spaces):
Input 1 outputs nothing, while Input 2 correctly prints the component's content.
Is there any way to make
markdown-to-jsx
more resilient to whitespaces so that both syntax works ?I have been struggling like 3 hours just to understand where was my mistake while it was just a space messing... :/
Anyway, nice library :)
The text was updated successfully, but these errors were encountered: