Skip to content

Commit

Permalink
feat: Use org-log-into-drawer to get LOGBOOK drawer name
Browse files Browse the repository at this point in the history
Don't assume that the LOGBOOK drawer name will always be named
"LOGBOOK".
  • Loading branch information
kaushalmodi committed May 10, 2022
1 parent 194a321 commit dceb610
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
15 changes: 9 additions & 6 deletions ox-hugo.el
Expand Up @@ -1737,9 +1737,11 @@ channel."
"Transcode a DRAWER element from Org to appropriate Hugo front-matter.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
(let ((drawer-name (downcase (org-element-property :drawer-name drawer))))
(let* ((logbook-drawer-name (org-log-into-drawer))
(drawer-name (org-element-property :drawer-name drawer)))
(message "dbg: %S" logbook-drawer-name)
(cond
((string= "logbook" drawer-name)
((equal logbook-drawer-name drawer-name)
;; (message "[ox-hugo logbook DBG] elem type: %s" (org-element-type drawer))
;; (pp drawer)

Expand Down Expand Up @@ -3985,11 +3987,12 @@ INFO is a plist used as a communication channel."
(data `,(append data weight-data custom-fm-data
(list
(cons 'menu menu-alist)
(cons 'resources resources)
;; (cons 'logbook-entries (plist-get info :logbook-entries))
(cons 'logbook (list
(cons 'notes (plist-get info :logbook-notes)))))))
(cons 'resources resources))))
ret)

(when (plist-get info :logbook-notes)
(setq data (append data `((logbook . ((notes . ,(plist-get info :logbook-notes))))))))

;; (message "[get fm DBG] tags: %s" tags)
;; (message "dbg: hugo tags: %S" (plist-get info :hugo-tags))
;; (message "[get fm info DBG] %S" info)
Expand Down
8 changes: 4 additions & 4 deletions test/site/content-org/all-posts.org
Expand Up @@ -7308,7 +7308,7 @@ This test removes the ~foo~ front-matter key from the exported file
:LOGBOOK:
- Note taken on [2022-05-04 Wed 13:15] \\
This new note added last should be the first element of the
~[[logbook_notes]]~ TOML table array.
~[[logbook.notes]]~ TOML table array.
- Note taken on [2022-04-08 Fri 14:53] \\
This note addition prompt shows up on typing the ~C-c C-z~ binding.
See [[info:org#Drawers]].
Expand All @@ -7322,7 +7322,7 @@ This test removes the ~foo~ front-matter key from the exported file
:END:
#+begin_description
Parse notes from LOGBOOK into a TOML table (YAML map?) of
~logbook_notes~ front-matter.
~logbook.notes~ front-matter.
#+end_description

{{{oxhugoissue(203)}}}
Expand All @@ -7342,12 +7342,12 @@ For example,
#+end_src

should export only the notes to an array of TOML tables with key
~logbook_notes~. The notes are ordered starting from the newest note
~logbook.notes~. The notes are ordered starting from the newest note
first in the TOML table array to the oldest note at the last.

- Note :: The state change notes are intentionally put in this test
LOGBOOK, because we want to ensure that they don't seep into the
~logbook_notes~ front-matter.
~logbook.notes~ front-matter.
** Extra Front-matter tests :extra:verbatim:src_block:
*** Extra Front-matter
:PROPERTIES:
Expand Down
8 changes: 4 additions & 4 deletions test/site/content/posts/parsing-notes-from-logbook.md
Expand Up @@ -2,7 +2,7 @@
title = "Parsing notes from LOGBOOK"
description = """
Parse notes from LOGBOOK into a TOML table (YAML map?) of
`logbook_notes` front-matter.
`logbook.notes` front-matter.
"""
tags = ["front-matter", "notes", "logbook"]
draft = false
Expand All @@ -11,7 +11,7 @@ draft = false
timestamp = 2022-05-04T13:15:00+00:00
note = """
This new note added last should be the first element of the
`[[logbook_notes]]` TOML table array.
`[[logbook.notes]]` TOML table array.
"""
[[logbook.notes]]
timestamp = 2022-04-08T14:53:00+00:00
Expand Down Expand Up @@ -44,10 +44,10 @@ For example,
```

should export only the notes to an array of TOML tables with key
`logbook_notes`. The notes are ordered starting from the newest note
`logbook.notes`. The notes are ordered starting from the newest note
first in the TOML table array to the oldest note at the last.

Note
: The state change notes are intentionally put in this test
LOGBOOK, because we want to ensure that they don't seep into the
`logbook_notes` front-matter.
`logbook.notes` front-matter.

0 comments on commit dceb610

Please sign in to comment.