holoviz / panel

Panel: The powerful data exploration & web app framework for Python
https://panel.holoviz.org
BSD 3-Clause "New" or "Revised" License
4.64k stars 504 forks source link

Improve Markdown Experience #4149

Open MarcSkovMadsen opened 1 year ago

MarcSkovMadsen commented 1 year ago

The Markdown experience of Panel could be improved. It would improve a lot of users and use cases.

Markdown is very important for the first experience of a data app framework.

As you can see below Markdown does not work well in Panel. And beginners and users looking for writing reports in Panel will currently have a hard time.

Example: Comparison to Streamlit

Bigger Headers

Streamlits headers are bigger and thicker which makes them more readable. Data Apps are often also used a bit like a power point where there are some key messages (headers) that should clearly stand out.

image

Anchor links

You can link directly to sections of bigger Streamlit apps

image.

This makes sharing information with colleagues so much easier.

Code sections

Streamlits code sections stands out more clearly

image

Tables

Panels tables are not formatted

image

Fenced Code Blocks

Streamlits fenced code blocks look much better. And the built in copy functionality is so powerful

image

Footnotes

Here Panel is better

image

Strikethrough

Not supported by Panel

image

Task List

Streamlits looks so much better

image

Emoji

Not supported by Panel

image

Bokeh Layout Issues

Very often the Bokeh layout engine cannot figure out how heigh the markdown section should be

image

Code

Streamlit provides a dedicated st.code functionality. That is pretty useful. The code section stands out and uses friendlier colors.

image

Panel Code

import panel as pn
import requests

pn.extension(sizing_mode="stretch_width", template="fast")

@pn.cache()
def get_text():
    url = "https://www.markdownguide.org/assets/markdown-cheat-sheet.md"
    return requests.get(url).text
text = get_text()

pn.pane.Markdown(text).servable()

pn.pane.Markdown("""
``python
import panel as pn
import requests

pn.extension(sizing_mode="stretch_width", template="fast")

@pn.cache()
def get_text():
    url = "https://www.markdownguide.org/assets/markdown-cheat-sheet.md"
    return requests.get(url).text
text = get_text()

pn.pane.Markdown(text).servable()
``
""").servable()

Streamlit Code

import streamlit as st
import requests

@st.cache()
def get_text():
    url = "https://www.markdownguide.org/assets/markdown-cheat-sheet.md"
    return requests.get(url).text
text = get_text()

st.write(text)

st.code("""
import streamlit as st
import requests

@st.cache()
def get_text():
    url = "https://www.markdownguide.org/assets/markdown-cheat-sheet.md"
    return requests.get(url).text
text = get_text()

st.write(text)
""")
MarcSkovMadsen commented 1 year ago

Panel does not have coloring. Streamlit will soon have

image

philippjfr commented 1 year ago

Highly appreciate this excellent writeup @MarcSkovMadsen!

philippjfr commented 1 year ago

Most items here have now been addressed, I'll bump to next to address any remaining missing features and perhaps switch to markdown-it client-side.

MarcSkovMadsen commented 1 year ago

If tried inserting the content of https://www.markdownguide.org/assets/markdown-cheat-sheet.md in the Markdown pane reference notebook. The things still not supported with the default plugins are below.

image

Besides that, I would say better table styling (in notebook) would be awesome.

philippjfr commented 1 year ago

Hmm, definition lists should be supported, and I'm really surprised I haven't been able to find sub and superscript extensions for the markdown-it-py. Also wish the emoji extension was on conda defaults so I could require it.

MarcSkovMadsen commented 1 year ago

Hm. Maybe the definition lists are not very clearly styled? It gets correctly indented.