emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* ox-publish index allows alternative formats?
@ 2023-07-24 13:28 Britt Anderson
  2023-07-25  8:11 ` Ihor Radchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Britt Anderson @ 2023-07-24 13:28 UTC (permalink / raw)
  To: emacs-orgmode

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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-25  8:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-24 13:28 ox-publish index allows alternative formats? Britt Anderson
2023-07-25  8:11 ` Ihor Radchenko

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).