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

Memoize markdown component_map #2219

Merged
merged 7 commits into from
Nov 28, 2023
Merged

Memoize markdown component_map #2219

merged 7 commits into from
Nov 28, 2023

Conversation

masenf
Copy link
Collaborator

@masenf masenf commented Nov 24, 2023

  1. automatically memoize the component_map passed to the markdown component
  2. support state and other Var hooks/imports within markdown component_map components
  3. support simple rx.cond for code_block theme prop
  4. support arbitrary depth code_block in markdown component_map

Address #2217 (or at least part of it)

@masenf masenf changed the base branch from masenf/memoize-separate to main November 28, 2023 00:06
The SyntaxHighlighter component is more reliable when the code itself is passed
via prop, rather than passed as an actual child. So save any passed child to
the `code` prop. And then render the contents of the `code` prop as `children=`
special prop (similar to how the rx.markdown component did it)

Using this new mechanism, the SyntaxHighlighter can work with rx.markdown at
arbitrary nesting levels (for example, when used with a custom component_map)
Always move the component map to a separate function (and include any hooks, so
the components can access state/colorMode).

This allows the markdown component itself to not depend on state (and thus be
rendered directly in the page) while having its constituent components depend
on state.
@masenf masenf force-pushed the masenf/markdown-component-map branch from 3f7183c to e379393 Compare November 28, 2023 00:07
@masenf masenf closed this Nov 28, 2023
@masenf masenf reopened this Nov 28, 2023
@picklelo picklelo merged commit 626357e into main Nov 28, 2023
45 checks passed
@masenf masenf deleted the masenf/markdown-component-map branch December 6, 2023 22:16
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.

2 participants