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

Change markdown rendering to set breaks to false #5368

Merged
merged 6 commits into from Aug 29, 2023
Merged

Change markdown rendering to set breaks to false #5368

merged 6 commits into from Aug 29, 2023

Conversation

abidlabs
Copy link
Member

@abidlabs abidlabs commented Aug 29, 2023

Disables new line breaks unless two new lines have been entered, in accordance with commonmarkspec

Closes: #5356
Closes: #5362

Test with:

import gradio as gr

markdown = r"""$$
\\begin{pmatrix}
   a & b \\\\
   c & d
\\end{pmatrix}
$$
"""

markdown2 = """
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over
the lazy dog.

The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog. The quick brown fox jumps over\
the lazy dog.

The quick brown fox jumps over the lazy dog. The quick brown fox jumps over 

the lazy dog.
"""


with gr.Blocks() as demo:
    gr.Markdown(markdown2, latex_delimiters=[{ "left": "$$", "right": "$$", "display": True }])
    gr.Markdown(markdown, latex_delimiters=[{ "left": "$$", "right": "$$", "display": True }])
demo.queue().launch()

Updates Markdown stories as well.

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Aug 29, 2023

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
Visual tests all good! Build review
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/1603794cc0a2815cab42eba0377b0810c74d2b5a/gradio-3.41.2-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@1603794cc0a2815cab42eba0377b0810c74d2b5a#subdirectory=client/python"

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Aug 29, 2023

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/markdown patch
gradio patch
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Change markdown rendering to set breaks to false

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@abidlabs abidlabs mentioned this pull request Aug 29, 2023
1 task
Copy link
Collaborator

@aliabid94 aliabid94 left a comment

Choose a reason for hiding this comment

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

LGTM!

@abidlabs
Copy link
Member Author

Thanks @aliabid94!

@abidlabs abidlabs merged commit b27f758 into main Aug 29, 2023
14 checks passed
@abidlabs abidlabs deleted the md-breaks branch August 29, 2023 18:20
@pngwn pngwn mentioned this pull request Aug 29, 2023
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.

Render complex Latex formulas new lines in gr.Markdown
3 participants