On 2025-03-04, 16:45 -0300, Jonathan Gregory <j...@autistici.org> wrote:
> You're right, the ~org-list-to-subtree~ function treats lists as
> outline items. You can try inserting lists as plain Org content
> directly:

Hi Jonathan,

Thanks so much for helping with this. Sorry for my delayed reply, last
week got unexpectedly busy.

I'll test your function asap and integrate it in my publishing
mechanism.

Perhaps I should reach out to ox-rss.el and ask whether this (or a
variation thereof) could get integrated as part of the library.
Publishing a full-content RSS seems to be pretty common use case.

> #+begin_src elisp
> (defun extract-org-content (entry)
>   "Extract the Org content from an ENTRY list."
>   ;; Skip the 'unordered' keyword
>   (when (and (listp entry) (> (length entry) 1))
>     (let* ((inner-list (cadr entry))
>            (content (if (and (listp inner-list) (listp (cadr 
>            inner-list)))
>                         (car (cadr inner-list))
>                       inner-list)))
>       (unless (equal content "nil") content))))
>
> (defun my/rss-feed-generate (title list)
>   "Generate the RSS feed as a string."
>   (with-temp-buffer
>     (insert "#+TITLE: " title "\n\n")
>     (dolist (entry list)
>       (let ((content (extract-org-content entry)))
>         (when content
>           ;; Ensure each post title is correctly formatted as 
>           level 1
>           (if (string-match "^\\* " content)
>               (insert "* " (string-trim (replace-regexp-in-string 
>               "^\\*+" "**" content)) "\n")

Should this be something like:

(string-trim (replace-regexp-in-string "^\\(\\*+\\)" "\\1*" "*** content"))

This way "* " becomes "** " but also "** " becomes "*** ", etc?

>             (insert content "\n"))))) ;; Insert other content as 
>             is
>     (buffer-string)))
> #+end_src
>
> This ensures that:
>
> 1. Post titles are kept as level 1
> 2. Subheadings are demoted correctly (* => **)
> 3. Unordered lists (- item) are preserved
>
> Hope this helps!

It does, thank you!

Cheers, Fabio.

Reply via email to