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

Markdown should render titles and headings with <a> tags to allow in-page links #824

Closed
nthmost opened this issue Dec 9, 2019 · 4 comments · Fixed by #2513
Closed

Markdown should render titles and headings with <a> tags to allow in-page links #824

nthmost opened this issue Dec 9, 2019 · 4 comments · Fixed by #2513
Assignees
Labels
feature:st.markdown type:enhancement Requests for feature enhancements or new features

Comments

@nthmost
Copy link
Contributor

nthmost commented Dec 9, 2019

Problem

It should be possible to make in-page links so that the app user can click on a title (e.g. within a Table of Contents) to reach the labeled part of the app quickly.

godot63 on the streamlit forum writes:

I would like to write something like:
[Station information](#Station-information)
where in the document there is a ‘# Station information’ title in the same doc. This seems to work on git but does not in my Streamlit app.

Links to look at:

Solution

MVP: The easiest thing is just to give every Markdown title and heading an automatic <a href="#title"> when it is rendered as HTML in React.

Possible enhancement: As an alternate or additional solution, it might be nice for users to have something like st.label("station-info") to create <a href="#station-info"> when the app is rendered. Then you could create in-page links without also needing to write a title or heading to the screen.

Additional context

https://discuss.streamlit.io/t/links-to-same-document-in-md-document/1265

@nthmost nthmost added the type:enhancement Requests for feature enhancements or new features label Dec 9, 2019
@nthmost nthmost self-assigned this Dec 9, 2019
@nthmost nthmost added the good first issue Good for newcomers label Dec 9, 2019
@nthmost nthmost changed the title Markdown should allow the creation of in-page links. Markdown should render titles and headings as "<a>" tags to allow in-page links Dec 9, 2019
@nthmost nthmost changed the title Markdown should render titles and headings as "<a>" tags to allow in-page links Markdown should render titles and headings as <a> tags to allow in-page links Dec 9, 2019
@nthmost nthmost changed the title Markdown should render titles and headings as <a> tags to allow in-page links Markdown should render titles and headings with <a> tags to allow in-page links Dec 9, 2019
@nthmost
Copy link
Contributor Author

nthmost commented Dec 10, 2019

per @tvst:

I think there's a design question there about whether the titles should be clickable at all
Or maybe we should show a ¶ sign on hover next to the title, and the sign is clickable

(Or maybe a 🔗 sign)

@nishnash54
Copy link

nishnash54 commented Apr 28, 2020

Is anyone working on this? I would love to contribute.
Let me know if anything is planned in regard to this issue. 😄

@nthmost
Copy link
Contributor Author

nthmost commented Jul 7, 2020

Hi @nishnash54, apologies for the late reply -- If you're interested in contributing on this feature, you can email me directly at naomi@streamlit.io -- we've been adjusting our policies in terms of coordinating community contributions, especially as our team has been growing quickly, plus an unexpected pandemic. :)

@nthmost
Copy link
Contributor Author

nthmost commented Jul 30, 2020

Clarifications per @treuille

  1. st.title, st.header, and st.subheader have an additional anchor kwarg
  2. By default anchor=None which implies that the anchor is set automatically to be a lower-dash-case version of the title text, e.g.:
    • st.title(‘Cooking Instructions‘) → the anchor is cooking-instructions
      • Same forst.write(‘# Cooking Instructions’)
    • st.subheader(‘Real-time rendering’) → the anchor is real-time-rendering
      • Same for st.write(‘## Real-time rendering’)
  3. Adding a #anchor to the URL automagically centers the page on that anchor
    • I think we get this for free, right? [yes]

wtype pushed a commit to wtype/streamlit that referenced this issue Aug 13, 2020
wtype pushed a commit to wtype/streamlit that referenced this issue Aug 13, 2020
wtype pushed a commit to wtype/streamlit that referenced this issue Aug 13, 2020
@exalate-issue-sync exalate-issue-sync bot added good_first_issue and removed good first issue Good for newcomers labels Nov 16, 2020
@ghost ghost closed this as completed in #2513 Jan 12, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:st.markdown type:enhancement Requests for feature enhancements or new features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants