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

feat: Toggle ommission of subheading content #673

Open ewollesen opened 1 year ago

ewollesen commented 1 year ago

Previously, when a heading was rendered, each of its subheadings' output was included in the output. With this change, a customizable variable is added that, if set, will omit those subheadings that have the :EXPORT_FILE_NAME property set from the output of their parent.

This can be handy for non-blogging sites, where the content is still hierarchical, but doesn't lend itself to the blogging format where a parent page includes the content of each of its children (like a year index page, month index page, etc.)

At the rist of being annoyingly verbose, before this change, if you had a post structure like this (in pseudo-org-mode format):

* Post A
  :EXPORT_FILE_NAME: post-a

  Some text.

** Post B
   :EXPORT_FILE_NAME: post-b

   Text that relates to Post B.

** Post C

   General text, but no :EXPORT_FILE_NAME.

When rendered into HTML at the URL of /posts/post-a/, one would see:

Post A

Some text.

Post B

Text that relates to Post B.

Post C

General text, but no :EXPORT_FILE_NAME.

…

After this change (and when the variable is set):

Post A

Some text.

Post C

General text, but no :EXPORT_FILE_NAME.

…

The premise is that Post B will have its own page (as indicated by the :EXPORT_FILE_NAME property) and so doesn't or shouldn't be included in the content of Post A.

ewollesen commented 1 year ago

I'm new to Elisp and ox-hugo, so apologies if I've done anything silly. I'll leave this as a draft for now while I go through all the contribution guidelines. However, if this isn't something you'd even be interested in, please let me know, so I don't waste my time with all the contribution hoop-jumping and what not. :)

Thanks for all your work, ox-hugo is great!

... oh, I'm off now to update my pandoc and write some tests.

ewollesen commented 1 year ago

I'm trying to run the tests, but they're failing in the Emacs version check. I believe this line is the indicator:

Debugger entered--Lisp error: (wrong-type-argument listp \(add-hook)
  loaddefs-generate--parse-file("/tmp/ericw/ox-hugo-dev/elpa_29/biblio-core-2021041..." "/tmp/ericw/ox-hugo-dev/elpa_29/biblio-core-2021041..." nil)

Grepping around, I found this:

/tmp/ericw/ox-hugo-dev/elpa_29/biblio-core-20210418.406/biblio-core.el
834-
835-;;;###autoload
836:3:\(add-hook \\='biblio-init-hook \\='YOUR-BACKEND-HERE).")
837-

I uhhh, don't really understand Elisp well enough to know what's going on there, but even if I did, I don't think I'd know how to fix whatever's wrong, since this seems to be a dependency.

Do you have any pointers for how I might work around this problem? I guess I'll comment out the emacs version check for now.

kaushalmodi commented 1 year ago

Hello, I cannot take a close look at this as I am on vacation. I'll be able to take a better look after October second week.

While you are working on this, also make sure sure that C-c C-e H H behaves as expected when the point is in each of the subtrees: A, B and C.

C-c C-e H A should also behave as expected: export 2 posts from your example.

If it results in complicating the existing code, I'd prefer to keep the simplicity of the current design rule: "A subtree with EXPORT_FILE_NAME cannot nest other post subtrees."

kaushalmodi commented 1 year ago

Hello @ewollesen , I have given some thought to this. I really like the simplicity of the rule that a subtree with EXPORT_FILE_NAME property needs to be the top-level for a post, and it cannot nest other EXPORT_FILE_NAME property sub-trees.

Can you please post a real example or point to one where you find the need to do so?