-
Notifications
You must be signed in to change notification settings - Fork 4k
Refactor CodeBlock.tsx #2814
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
Refactor CodeBlock.tsx #2814
Conversation
vdonato
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I'll wait on the other change to go in before +1-ing to prevent merges accidentally going in out of order.
I think this also technically will require @asaini to look at it since it's a behavioral change (I'm guessing both PRs can be reviewed at once), but I agree that the new behavior is more correct than defaulting to python if the requested language isn't supported.
vdonato
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to +1 before the prereq PR is merged since this + the prereq change are both waiting on the same product review and I'm sure accidentally hitting submit on this one first isn't a real concern
|
LGTM👍 The change described in this PR makes sense. Feels right to not show incorrect highlighting if a language is not supported. |
|
Awesome, just pending approval of #2808 then. |
* develop: (29 commits) Update bug_report.md Refactor CodeBlock.tsx (#2814) Remove copy button for empty codeblocks (#2808) Add image format deprecation config with expiration (#2865) Remove unneeded "use_column_width=True" from our doc examples (#2692) Extend our st.cache MagicMock handling logic to Mock (#2846) save work (#2862) Remove .stale-element class (#2848) Release 0.77 (#2849) Fix watchdog import failure (#2856) 🔥 Fully remove `format` param from st.image (#2637) Don't memoize config._server_headless (#2858) hide empty columns on mobile (#2756) st.beta_secrets (#2757) `watch_file` utility function (#2851) Align st.beta_columns (#2811) Update "showErrorDetails" config description and docs (#2841) Pause Dependabot updates for non-security-related issues (#2840) client.showTracebacks -> showErrorDetails (per product) (#2837) Color picker - show value (#2817) ...
We changed the behavior of auto-syntax highlighting in code blocks in streamlit#2814 to *not* attempt to highlight code as if it were python if the language specified isn't a supported one, which had the side effect of removing syntax highlighting from toml code blocks (toml was being highlighted as if it were python). This change adds toml highlighting back using prismjs' native support. We also re-order and re-group the imports in the file.
We changed the behavior of auto-syntax highlighting in code blocks in #2814 to *not* attempt to highlight code as if it were python if the language specified isn't a supported one, which had the side effect of removing syntax highlighting from toml code blocks (toml was being highlighted as if it were python). This change adds toml highlighting back using prismjs' native support. We also re-order and re-group the imports in the file.
Refactors CodeBlock per suggestion here. I also changed some of the logic around handling different values of
language. Our old logic was:languagein table of supported languagesThis is slightly incorrect; it should only default to Python if no language is requested. If a language is requested but not supported, we should just not highlight — if the user requests Brainfuck and we default to Python, we'll just produce incorrect highlighting.
(Forked this branch off #2808, the diff will shrink once that's merged.)