Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Feb 18, 2021

Refactors CodeBlock per suggestion here. I also changed some of the logic around handling different values of language. Our old logic was:

  • blindly look up language in table of supported languages
  • if found, use it; if not, default to Python

This 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.)

@ghost ghost self-requested a review February 18, 2021 18:21
@ghost ghost requested a review from vdonato February 18, 2021 18:23
Copy link
Collaborator

@vdonato vdonato left a 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.

Copy link
Collaborator

@vdonato vdonato left a 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

@asaini
Copy link

asaini commented Feb 25, 2021

LGTM👍

The change described in this PR makes sense. Feels right to not show incorrect highlighting if a language is not supported.

@ghost
Copy link
Author

ghost commented Feb 25, 2021

Awesome, just pending approval of #2808 then.

@ghost ghost merged commit fe1ac08 into streamlit:develop Feb 26, 2021
@ghost ghost deleted the refactor-codeblock branch February 26, 2021 19:42
tconkling added a commit that referenced this pull request Mar 1, 2021
* 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)
  ...
vdonato added a commit to vdonato/streamlit that referenced this pull request Apr 26, 2021
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.
vdonato added a commit that referenced this pull request May 13, 2021
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.
This pull request was closed.
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

Successfully merging this pull request may close these issues.

3 participants