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

Improvements to custom styles in rx.markdown #1852

Merged
merged 17 commits into from
Sep 25, 2023
Merged

Improvements to custom styles in rx.markdown #1852

merged 17 commits into from
Sep 25, 2023

Conversation

picklelo
Copy link
Contributor

@picklelo picklelo commented Sep 21, 2023

Added option to set custom styles using a component map:

component_map = {
    "h1": lambda text: rx.box(rx.heading(text), rx.divider())
    "p": rx.text
}

Then pass it in

source = """
# Hello!

Welcome to my markdown file.
"""

rx.markdown(
    source,
    component_map=component_map
)

masenf
masenf previously approved these changes Sep 21, 2023
Copy link
Collaborator

@masenf masenf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be cool to add e2e tests for the new var operations in integration/test_var_operations.py.

is this enough to fix #1283 too?

@@ -38,43 +52,18 @@ class Markdown(Component):

is_default = True

# Custom defined styles for the markdown elements.
custom_styles: Dict[str, Style] = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we probably should deprecate this first, unless you think no one is using it or it's already broken

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes agreed, I will add this for the following release I think I can make the old version convert cleanly to the new one.

@picklelo picklelo marked this pull request as draft September 21, 2023 23:32
@picklelo picklelo linked an issue Sep 25, 2023 that may be closed by this pull request
@picklelo picklelo marked this pull request as ready for review September 25, 2023 02:16
masenf
masenf previously approved these changes Sep 25, 2023
@@ -398,7 +398,7 @@ def frontend(self, driver_clz: Optional[Type["WebDriver"]] = None) -> "WebDriver
)
if self.frontend_url is None:
raise RuntimeError("Frontend is not running.")
driver = driver_clz() if driver_clz is not None else webdriver.Chrome()
driver = driver_clz() if driver_clz is not None else webdriver.Firefox()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if we want to commit this...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this, just had it locally for testing

@picklelo picklelo merged commit 8231993 into main Sep 25, 2023
@picklelo picklelo deleted the nikhil/markdown3 branch October 9, 2023 21:07
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.

Support custom styles for rx.markdown
2 participants