kaushalmodi / ox-hugo

A carefully crafted Org exporter back-end for Hugo
https://ox-hugo.scripter.co
GNU General Public License v3.0
868 stars 130 forks source link

Upstream bug maybe? #+attr_html: :class foo on tables is inserting <!--raw HTML omitted--> in final output #323

Closed jrmiller82 closed 4 years ago

jrmiller82 commented 4 years ago

org text looks like this:

#+CAPTION: Publish Dates of Dungeons and Dragons Editions
#+attr_html: :class table table-hover
| Date Published | Edition                   |
|----------------+---------------------------|
|           1974 | Original                  |
|           1977 | Basic Set Version 1       |
|           1977 | Advanced Edition 1        |
|           1981 | Basic Set Version 2       |
|           1983 | Basic Set Version 3       |
|           1989 | Advanced Edition 2        |
|           2000 | Third Edition             |
|           2003 | 3.5                       |
|           2008 | Fourth Edition            |
|           2014 | Fifth Edition (/current/) |

And C-c C-e H H leads to the following markdown:

<div class="ox-hugo-table table table-hover">
<div></div>
<div class="table-caption">
  <span class="table-number">Table 1</span>:
  Publish Dates of Dungeons and Dragons Editions
</div>

| Date Published | Edition                   |
|----------------|---------------------------|
| 1974           | Original                  |
| 1977           | Basic Set Version 1       |
| 1977           | Advanced Edition 1        |
| 1981           | Basic Set Version 2       |
| 1983           | Basic Set Version 3       |
| 1989           | Advanced Edition 2        |
| 2000           | Third Edition             |
| 2003           | 3.5                       |
| 2008           | Fourth Edition            |
| 2014           | Fifth Edition (_current_) |

</div>

Which then gives us the following html:

<!-- raw HTML omitted -->
<table>
<thead>
<tr>
<th>Date Published</th>
<th>Edition</th>
</tr>
</thead>
<tbody>
<tr>
<td>1974</td>
<td>Original</td>
</tr>
<tr>
<td>1977</td>
<td>Basic Set Version 1</td>
</tr>
<tr>
<td>1977</td>
<td>Advanced Edition 1</td>
</tr>
<tr>
<td>1981</td>
<td>Basic Set Version 2</td>
</tr>
<tr>
<td>1983</td>
<td>Basic Set Version 3</td>
</tr>
<tr>
<td>1989</td>
<td>Advanced Edition 2</td>
</tr>
<tr>
<td>2000</td>
<td>Third Edition</td>
</tr>
<tr>
<td>2003</td>
<td>3.5</td>
</tr>
<tr>
<td>2008</td>
<td>Fourth Edition</td>
</tr>
<tr>
<td>2014</td>
<td>Fifth Edition (<em>current</em>)</td>
</tr>
</tbody>
</table>
<!-- raw HTML omitted -->

See the <!--raw HTML omitted -->? That's the unexpected behavior.

jrmiller82 commented 4 years ago

Ahhh. It's a hugo v60 and onwards effect of their new markdown parser. See discussion here: https://discourse.gohugo.io/t/raw-html-getting-omitted-in-0-60-0/22032/5

Can be fixed by adding the following to your hugo config.toml:

[markup.goldmark.renderer]
unsafe= true

Maybe this is something get added to the documentation on table styling?

kaushalmodi commented 4 years ago

Maybe this is something get added to the documentation on table styling?

No, it's not just table styling. I recommend putting that setting in your site's config.toml if using ox-hugo.

I am already tracking this at this pinned issue https://github.com/kaushalmodi/ox-hugo/issues/307:

image


It was quite silly for the Hugo developer to change the default behavior of allowing inline HTML when upgrading from BlackFriday to Goldmark. Little bit more of my venting on that topic: here and here.

jrmiller82 commented 4 years ago

So when #307 is implemented, the docs will state that the unsafe=true configuration is needed for goldmark? I don't really care where in the docs it is stated, just that is is stated somewhere. My thought is that users shouldn't need to reference github issues to implement items / examples that are already in the docs.

kaushalmodi commented 4 years ago

So when #307 is implemented, the docs will state that the unsafe=true configuration is needed for goldmark?

That's correct. I referenced that issue and closed this one as this is very closely related to an already open issue.