kaushalmodi / ox-hugo

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

Overriding how headings are exported #725

Open andreyorst opened 10 months ago

andreyorst commented 10 months ago

Hi! I would like to ask if it is possible to add an extension point to the org-hugo-heading function in order to tweak how certain headings are exported. Right now I want to make a page on my blog that lists some collapsable items, created with the <details> tag, but I want to keep the outline capabilities in the Org file itself too. So, after exporting, the end result on the page should be something similar to what Emacs does in the buffer, allowing me to fold headings.

In other words, in my specific case, I was trying to transform this:

* heading
text
* heading 2
text 2

Into this:

<details>
<summary><h1>heading</h1></summary>
text
</details>

<details>
<summary><h1>heading 2</h1></summary>
text 2
</details>

But I can imagine more cases when someone wants to transform headings and their contents into something else.

I've already achieved this by advising the function and checking for a custom property so here I'm just asking if you think this makes sense to add this kind of feature to the package itself.

There are already some ways to configure how headings are exported, for example, you can set the N in #+options: H:N to some number and after this depth, the headings are transformed into list items. So maybe there's space for a more generic mechanism.

If you're OK with this, I can look into implementing it, if not define-advice it is :)