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

Add MDX support to the GUI API #73

Merged
merged 11 commits into from
Aug 8, 2023
Merged

Add MDX support to the GUI API #73

merged 11 commits into from
Aug 8, 2023

Conversation

jonahbedouch
Copy link
Contributor

Some of the code here is probably a bit weird, but this PR provides the ability for Viser to accept MDX from Python that gets rendered in real time on the client.

It does so with the interface:

server.add_gui_markdown(markdown: str, images: Optional[Dict[str, onp.ndarray]]) -> GuiMarkdownHandle

Where markdown is the provided mdx and images is an optional dictionary of named local images that the mdx can draw from (alongside any remote images).

Example 14 highlights an actual use case of how this works and the results, since the outcome is a little large for a screenshot.

@brentyi brentyi enabled auto-merge (squash) August 8, 2023 09:39
@brentyi brentyi merged commit 046b813 into main Aug 8, 2023
11 checks passed
@brentyi brentyi deleted the jonah/mdx branch August 8, 2023 09:43
yzslab pushed a commit to yzslab/viser that referenced this pull request Oct 20, 2024
* Create JSX component that processes markdown using MDX 2

* Add markdown to the GUI API and style it on the client

* Update Example 14 to be scoped per-client

* Move GUI Handles for Folders, Tabs, and Markdown to _gui_handles.py

* Use regex literals to resolve 'Unsupported Escape Sequence' warnings

* Update interface to intake a image_root Path and replace relative paths in mdx

This gets around introducing custom syntax that isn't being processed by mdx

* Remove custom placeholder from markdown image

As far as I can tell it doesn't work for images without a predefined aspect ratio

* Tweak markdown support
- Remove <img src="" /> => data URL logic
- Add .visible support

* Prettier

---------

Co-authored-by: Brent Yi <[email protected]>
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