Skip to content

Commit 5a4ae49

Browse files
Fix markdown link rendering in docs descriptions (#11774)
* fix link rendering * add changeset * autorecognize links * revert login button changes * add changeset --------- Co-authored-by: gradio-pr-bot <[email protected]>
1 parent 38427c4 commit 5a4ae49

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

.changeset/fast-garlics-lay.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"gradio": minor
3+
"website": minor
4+
---
5+
6+
feat:Fix markdown link rendering in docs descriptions

gradio/components/login_button.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class LoginButton(Button):
2727
retrieve a signed-in user's profile by adding a parameter of type `gr.OAuthProfile`
2828
to any Gradio function. This will only work if this Gradio app is running in a
2929
Hugging Face Space. Permissions for the OAuth app can be configured in the Spaces
30-
README file, as described here: <a href="https://huggingface.co/docs/hub/en/spaces-oauth" target="_blank">Spaces OAuth Docs</a>.
30+
README file, as described here: https://huggingface.co/docs/hub/en/spaces-oauth.
3131
For local development, instead of OAuth, the local Hugging Face account that is
3232
logged in (via `hf auth login`) will be available through the `gr.OAuthProfile`
3333
object.

js/_website/src/lib/text.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const regex_italic = /\*(.*?)\*/g;
22
const regex_code = /`(.*?)`/g;
33
const regex_curly_brackets = /\{(.*?)\}/g;
4+
const regex_auto_links = /\b(https?:\/\/\S+)/g;
45

56
export function style_formatted_text(formatted_text: string | null): string {
67
if (!formatted_text) return "";
@@ -15,7 +16,7 @@ export function style_formatted_text(formatted_text: string | null): string {
1516
"<code class='text-orange-500' style='font-family: monospace; font-size: 0.9em;'>$1</code>"
1617
)
1718
.replace(
18-
/\[(.*?)\]\((.*?)\)/g,
19-
"<a href='$2' class= 'text-orange-500'>$1</a>"
19+
regex_auto_links,
20+
"<a href='$1' target='_blank' class='text-orange-500'>$1</a>"
2021
);
2122
}

0 commit comments

Comments
 (0)