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

Link to markdown title with special characters #955

Open
hoorelbeke-jimmy opened this issue Feb 7, 2024 · 6 comments
Open

Link to markdown title with special characters #955

hoorelbeke-jimmy opened this issue Feb 7, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@hoorelbeke-jimmy
Copy link

hoorelbeke-jimmy commented Feb 7, 2024

Problem

I am displaying with streamlit some content, and I would like to display some links to markdown titles present on the streamlit page. For instance, the following is working:

import streamlit as st

st.markdown("# Introduction")
st.markdown("display some large text content")
st.markdown("[link](#introduction)") # does work

When I click on link, I return to the beginning of the section Introduction. However, this doesn't work when I use special characters in my title, for instance:

import streamlit as st

st.markdown("# Présentation")
st.markdown("display some large text content")
st.markdown("[link](#présentation)") # doesn't work
st.markdown("[link](#presentation)") # doesn't work either

To better understand the issue, I clicked on the anchor link on the left of the title "# Présentation", and I see on the URL that the link is "78e1d857" (for "# Introduction" it was "introduction").

My goal would be to be able to generate a link to the section "# Présentation" within my streamlit page, and for this I need to understand why the anchor link is "78e1d857". I tried to reverse engineer how to get this link based on the title content by looking at GitHub Flavored markdown, but I didn't find a way to do so.

Solution

MVP: A section in streamlit's documentation on how to do so would solve my issue.

Possible additions: A method in the streamlit package that returns the anchor link based on a makdown title would be even better

@hoorelbeke-jimmy hoorelbeke-jimmy added enhancement New feature or request needs triage labels Feb 7, 2024
@sfc-gh-dmatthews sfc-gh-dmatthews self-assigned this Feb 7, 2024
@sfc-gh-dmatthews
Copy link
Contributor

This is a great suggest, thanks!

@snehankekre
Copy link
Contributor

An alternative take: this should be an enhancement/feature request about anchors for streamlit/streamlit , not a workaround we should document.

@hoorelbeke-jimmy
Copy link
Author

An alternative take: this should be an enhancement/feature request about anchors for streamlit/streamlit , not a workaround we should document.

@snehankekre Do you want me to open an issue on streamlit ?

@snehankekre
Copy link
Contributor

That would be great! Thanks, @hoorelbeke-jimmy

@sfc-gh-dmatthews
Copy link
Contributor

sfc-gh-dmatthews commented Feb 9, 2024

Until it gets changed in OS, I can at least make a mention about the behavior. There is some other work to provide general advice on using links within Streamlit (what opens a new tab, anti-patterns that reset Session State, etc.) So when that goes together, this is an easy footnote until there is some change in the library. Good call registering it as a feature request, though. 👍🏻

@hoorelbeke-jimmy
Copy link
Author

I opened a feature request here streamlit/streamlit#8114

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants