emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Britt Anderson <britt@b3l.xyz>
To: emacs-orgmode@gnu.org
Subject: ox-publish index allows alternative formats?
Date: Mon, 24 Jul 2023 09:28:16 -0400	[thread overview]
Message-ID: <87mszlctmn.fsf@b3l.xyz> (raw)

Question:

Could ~:makeindex~ (in the ~org-publish-project-alist~) be expanded to
accept a user provided function for formatting the output differently?

Background: 

I am using org for a static website (brittanderson.github.io). I wanted
to make a list of blog posts subdivided by topic and I decided to use
~:makeindex~. I add ~#+Index: keyword~ lines to the preamble of the
posts and the list is generated, however I did not like the formatting.
It gave me a list of keywords as links (often repeated) with no context
(like title or date). So I hacked this alternative:
https://brittanderson.github.io/posts/theindex.html

It seems like it would be nice to allow users to provide their own
formatting functions to ~org-publish-index-generate-theindex~. Similar
to the way that ~:sitemap-function~ allows a user controlled sitemap.
I altered a few lines to do this for myself (as seen in the diff below),
but am unsure whether there is any more general interest in expanding
the index functionality or where in the org hierarchy would be the best
place to try and code such that ~:makeindex~ can be nil, 'default or the
name of a user provided function that expects one argument (to become
~target~). 

My question is whether this is something that is worth doing, and if it
is worth doing how hard should it be for a novice to attempt, and does
anyone have any pointers for how to tackle it?

-- Britt Anderson

My example of minor edits:

diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el
index 3c7311b56..d04c15fd5 100644
--- a/lisp/ox-publish.el
+++ b/lisp/ox-publish.el
@@ -1109,15 +1109,16 @@ publishing directory."
 		    ;; Last term: Link it to TARGET, if possible.
 		    (let ((target (nth 2 idx)))
 		      (format
-		       "[[%s][%s]]"
-		       ;; Destination.
+		       "*%s* [[%s]]"
+                       (car (last entry))
+                       ;; Destination.
 		       (pcase (car target)
 			 (`nil (format "file:%s" file))
 			 (`id (format "id:%s" (cdr target)))
 			 (`custom-id (format "file:%s::#%s" file (cdr target)))
 			 (_ (format "file:%s::*%s" file (cdr target))))
 		       ;; Description.
-		       (car (last entry)))))
+		       )))
 		  "\n"))))
 	    (setq current-letter letter last-entry entry))))
       ;; Create "theindex.org", if it doesn't exist yet, and provide



             reply	other threads:[~2023-07-24 13:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-24 13:28 Britt Anderson [this message]
2023-07-25  8:11 ` ox-publish index allows alternative formats? Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mszlctmn.fsf@b3l.xyz \
    --to=britt@b3l.xyz \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).