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
✨ Pretty Printing HTML in console.logs. #167
✨ Pretty Printing HTML in console.logs. #167
Conversation
Hey, Thaks for the PR. Could you please share how does the prettier make things better? A real example of before and after would be nice. And if it makes things better, we should try to consume it via npm rather than linking it via CDN :) Is there a particular reason for linking it via CDN? |
HI, I have updated the PR description with before and after images. The package I'm using is code-prettify from Google. Their instructions only show how to set-up using a CDN. I found an attempt here (react-code-prettify) at making it consumable via npm package. But |
Changed the after screenshot changing log fonts to monospace |
Hi again, Thanks for posing the images. It looks like it would be useful to have the console log pretty-printed if we are console logging Html. However, I would still like to go with an npm based solution. We could try the standalone prettier version if you are interested. https://prettier.io/docs/en/browser.html#commonjs |
Hey @Raathigesh , Good that you insisted! Apparently we don't need an external library to format HTML code. Wrapping it in |
💄 Uses `pre` to prettify logs in `console-panel/index.tsx` 💄 Change Log fonts to monospace 🚨 Add index as a key to `map` function in `console-panel/index`
b55f721
to
e71c849
Compare
@Raathigesh I am also looking into leveraging |
Hey, Can we merge this? |
Thanks for the Update. Let's make the react-inspector change in a separate PR. Just a quick question. How does the pre-change look for non-code values? |
I assume this PR resolves #163 If I understand that correctly |
Ah Right. Looks good to me. @allcontributors please add @rahulakrishna for code and idea |
I've put up a pull request to add @rahulakrishna! 🎉 |
Thank you for your PR. I will push a release by this week. |
@rahulakrishna did you start the PR to use react-inspector as a visualizer for DOM output? |
Haven't gotten around to it yet. |
Use
pre
tag to properly format HTML🚨 Add
index
as key tomap
insideconsole-panel/index.tsx
. This is to get rid of the error message in the console. Since we don't have any identifier for each log. React anyway defaults to using index as key when not explicitly given a key.Often times when working with tests I have to do
console.log(component.debug()
which outputs a prettified html code onto the console. Majestic however shows the whole component in a single line which can be hard to debug.Before:
After: