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

Is it possible to generate borders with Markdown tables #863

Closed
Jacob-Barhak opened this issue Sep 30, 2019 · 4 comments
Closed

Is it possible to generate borders with Markdown tables #863

Jacob-Barhak opened this issue Sep 30, 2019 · 4 comments

Comments

@Jacob-Barhak
Copy link

The panel group redirected me to your issue tracker to see if markdown can provide remedy for this issue.

I am using panel that uses markdown and I am trying to generate a table with borders. Here is the code I am using in panel:

import panel as pn
from bokeh.resources import INLINE

SimpleTable = pn.panel("""
|     Time    | Number of Trial with Results | Unique Units |
|:-----------:|:----------------------------:|:------------:|
| 20 Apr 2018 |            30,763            |    21,094    |
|  7 Feb 2019 |            34,751            |    23,733    |
| 12 Apr 2019 |            35,926            |    24,548    |
|             |                              |              |

""")

SimpleTable.save('SimpleTable', resources=INLINE) 

The code generates a nice table, yet without borders.

image

Now the question is whether you can force table borders to be drawn in markdown or are visual look aspects need to be handled elsewhere by panel, bokeh, or some CSS.

It may be a question open for debate - will be happy to get feedback.

@jbednar
Copy link

jbednar commented Sep 30, 2019

For what it's worth, I think what Panel is doing with the input above is effectively:

import markdown

str = """
|     Time    | Number of Trial with Results | Unique Units |
|:-----------:|:----------------------------:|:------------:|
| 20 Apr 2018 |            30,763            |    21,094    |
|  7 Feb 2019 |            34,751            |    23,733    |
| 12 Apr 2019 |            35,926            |    24,548    |
|             |                              |              |
"""

extensions = ['markdown.extensions.extra', 'markdown.extensions.smarty']
html = markdown.markdown(str, extensions=extensions, output_format='html5')

The resulting html looks like this in a web browser if put in a bare page:

image

And like this in a Jupyter notebook cell:

from IPython.display import HTML
HTML(html)

image

So it's possible to style it, presumably using the usual table CSS properties.

@Jacob-Barhak
Copy link
Author

In that case, unless Markdown developers want to add more features related to CSS style, it seems we can close this in this issue tracker.

@waylan
Copy link
Member

waylan commented Sep 30, 2019

Python-Markdown simply outputs standard HTML for tables. As explained in the Markdown syntax rules "HTML is a publishing format; Markdown is a writing format." Whether borders are displayed and/or the style of those borders are publishing matters and outside the scope of Markdown. However, basic CSS rules for styling the HTML will work fine. In fact, as @jbednar points out, different tools use different default styles for the same input. If you want to use custom styles, you need to explore what provisions your tool uses to define custom styles.

@Jacob-Barhak Jacob-Barhak changed the title Is is possible to generate borders with Markdown tables Is it possible to generate borders with Markdown tables Sep 30, 2019
@Jacob-Barhak
Copy link
Author

Thanks Waylan,

There is a temporary solution found that can be found here: holoviz/panel#668

It may not be very elegant, yet it seems to work for a simple example. Thanks for the feedback.

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

No branches or pull requests

3 participants