HTML tables being omitted

Hi all

I am new to Hugo. I have been using Nikola for my blog but am looking at moving over. I use Jupyter notebooks for a lot of my notebooks, and these in turn often have renderings of pandas dataframes, which get rendered as HTML divs that contain a style element and a table element.

<div>
<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>
<table border="1" class="dataframe">
  ...
</table>
</div>

In Hugo these are getting rendered completely wrong. The contents of the style element are being included in the output as text, while the table is not rendered at all.

I’ve seen the comments about setting the renderer to allow unsafe HTML and already have this in my config.yaml file:

markup:
  goldmark:
    renderer:
      unsafe: true

It sounds like that should fix things but it doesn’t. Any suggestions?

Thanks
G.

If you want to add a style to your content, you have to use… style. Somthing like

<style>
.dataframe tbody... { rules...}
</style>

With pre and code, you just show your code to your users!

unsafe=true does fix this, which means that you somehow got the configuration syntax wrong.

1 Like

Ah, you are right. I had copied a bunch of configuration settings over from the theme I am using. That content also had a ‘markup’ section, so it must have been overriding the earlier ‘markup’ section I had. I folded the subsections into a single ‘markup’ section and now it is working.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.