From b27f7583254165b135bf1496a7d8c489a62ba96f Mon Sep 17 00:00:00 2001 From: Abubakar Abid <abubakar@huggingface.co> Date: Tue, 29 Aug 2023 11:20:41 -0700 Subject: [PATCH] Change markdown rendering to set breaks to false (#5368) * change markdown rendering to set breaks to false * add changeset * update stories * lint --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> --- .changeset/shy-fans-chew.md | 6 ++++++ js/markdown/Markdown.stories.svelte | 26 +++++++++++++++++++++----- js/markdown/static/utils.ts | 2 +- 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 .changeset/shy-fans-chew.md diff --git a/.changeset/shy-fans-chew.md b/.changeset/shy-fans-chew.md new file mode 100644 index 0000000000..7d435fb9e7 --- /dev/null +++ b/.changeset/shy-fans-chew.md @@ -0,0 +1,6 @@ +--- +"@gradio/markdown": patch +"gradio": patch +--- + +fix:Change markdown rendering to set breaks to false diff --git a/js/markdown/Markdown.stories.svelte b/js/markdown/Markdown.stories.svelte index baf522a61a..7c398b0a5f 100644 --- a/js/markdown/Markdown.stories.svelte +++ b/js/markdown/Markdown.stories.svelte @@ -18,17 +18,33 @@ <Template let:args> <Markdown - value="Here's some <strong>bold</strong> text. And some <em>italics</em> and some <code>code</code>" + value="Here's some **bold** text. And some *italics* and some `code`" + latex_delimiters={[]} {...args} /> </Template> -<Story name="Simple inline Markdown with HTML" /> - -<Story name="Right aligned Markdown with HTML" args={{ rtl: true }} /> +<Story name="Simple inline Markdown" /> <Story - name="Markdown with math" + name="Multiline Markdown" + args={{ + value: ` +This should +all be in one line. + +--- + +This should be + +in two separate lines.` + }} +/> + +<Story name="Right aligned Markdown" args={{ rtl: true }} /> + +<Story + name="Markdown with LaTeX" args={{ value: "What is the solution of $y=x^2$?", latex_delimiters: [{ left: "$", right: "$", display: false }] diff --git a/js/markdown/static/utils.ts b/js/markdown/static/utils.ts index afdc1afb2f..22341c6cfc 100644 --- a/js/markdown/static/utils.ts +++ b/js/markdown/static/utils.ts @@ -107,7 +107,7 @@ const renderer: Partial<Omit<Renderer, "constructor" | "options">> = { marked.use( { gfm: true, - breaks: true, + breaks: false, pedantic: false, headerIds: false, mangle: false