nbdev icon indicating copy to clipboard operation
nbdev copied to clipboard

Dataframe HTML tags showing up in exported README

Open rxavier opened this issue 3 years ago • 5 comments

Related to https://github.com/fastai/nbdev/issues/474

Rendered readme on Github: https://github.com/rxavier/poniard/blob/experiment/nbdev/README.md index.ipynb: https://github.com/rxavier/poniard/blob/experiment/nbdev/nbs/index.ipynb

Basically, "raw output" dataframes (for example, when a method simply returns a dataframe, like get_results in this example) get this added before the actual table in markdown:

<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>

Meanwhile, dataframes rendered with display(HTML(df.to_html())) (which shows after setup in this example) display fine.

Quarto HTML docs render any of these fine.

Edit: I implemented an ugly temporary fix by using directives and ipython's display:

#| output: false

obj.method_that_outputs_a_df()
#| echo: false

from ipython import display, HTML

df = obj.method_that_outputs_a_df()
display(HTML(df.to_html()))

rxavier avatar Oct 12 '22 19:10 rxavier

Is this still an issue? I can't find the <style> tags in your current README.md

seeM avatar Oct 16 '22 11:10 seeM

Yeah, it is. I implemented an ugly fix with directives and ipython display.

I'll fix the issue so the urls point to an earlier version where it can be seen.

rxavier avatar Oct 16 '22 11:10 rxavier

Hey I have this same issue on the readme of this project which is generated from the notebook in nbs/index.ipynb. The issue is that when I print a dataframe, the HTML tags for the style do show up in the readme.

Did you have any success in fixing this? I can still see the tags in your readme @rxavier

Attol8 avatar Mar 01 '23 17:03 Attol8

Hi @Attol8. The tags you're seeing in my readme are not related to the issue I reported here. I fixed this specific issue with the workaround in my first post

rxavier-ml avatar Mar 01 '23 18:03 rxavier-ml

@rxavier-ml understood thanks! Fixed the issue with your method, I believe it should be the default for nbdev readmes

Attol8 avatar Mar 03 '23 17:03 Attol8