emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ox-publish index allows alternative formats?


From: Britt Anderson
Subject: ox-publish index allows alternative formats?
Date: Mon, 24 Jul 2023 09:28:16 -0400
User-agent: mu4e 1.10.4; emacs 28.2

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 via email to

[Prev in Thread] Current Thread [Next in Thread]