I’m trying to create a table in my post. Here is a example :
| this is a test | this is a test |
|----------------+----------------|
| <r> | <c> |
| this | test |
It expected result is like:
this is a test
this is a test
this
test
But it actual result is:
this is a test
this is a test
this
test
This is the HTML code for table:
<table>
<thead>
<tr>
<th class="align-right">this is a test</th>
<th class="align-center">this is a test</th>
</tr>
</thead>
<tbody>
<tr>
<td class="align-right">this</td>
<td class="align-center">test</td>
</tr>
</tbody>
</table>
As you can see, Hugo incorrectly converted the align tag to class, the correct tag should be style. But I am not familiar with Go, how can I fix this bug?
I’m not sure how it should work but the class approach could be superior?
You get to set the alignment in css and you could also set something like a margin right on the right aligned ones.
Inlining the styles produces a better experience for new/casual users, similar to the way that syntax highlighting styles are inlined by default.
With syntax highlighting (Chroma) we can disable the inline styles in favor of an external style sheet created with hugo gen chromastyles --style monokai.
With tables, I suppose if inline styles were blocked by CSP, you could apply an external style by querying the style attribute (don’t judge, just saying…).
td[style="text-align:center"],
th[style="text-align:center"] {
text-align: center !important;
}
td[style="text-align:left"],
th[style="text-align:left"] {
text-align: left !important;
}
td[style="text-align:right"],
th[style="text-align:right"] {
text-align: right !important;
}