Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Parse date, lastmod and notes from LOGBOOK drawers #504

Merged
merged 19 commits into from
May 12, 2022
Merged

Conversation

kaushalmodi
Copy link
Owner

@kaushalmodi kaushalmodi commented Jan 5, 2022

Fixes #203

  • Fix run time error when parsing plist data only on Emacs 26.3 - https://lists.gnu.org/r/help-gnu-emacs/2022-05/msg00022.html -- The "fix" was actually a workaround to use alist instead of plist for the logbook entry.
  • Export LOGBOOK notes to logbook.notes TOML Table array
  • Interpret date from LOGBOOK state changes
  • Interpret lastmod from LOGBOOK state changes
  • Update ox-hugo manual with info on :LOGBOOK: drawer exports

Documentation

https://ox-hugo.scripter.co/doc/drawers/

Example usage

scripter.co commit # cae86abc

@kaushalmodi kaushalmodi changed the title WIP: logbook content parsing logbook content parsing Jan 5, 2022
@kaushalmodi kaushalmodi force-pushed the logbook branch 6 times, most recently from a988824 to d7d867c Compare January 11, 2022 22:00
@kaushalmodi kaushalmodi deleted the branch main February 10, 2022 16:44
@kaushalmodi kaushalmodi reopened this Feb 10, 2022
@kaushalmodi
Copy link
Owner Author

kaushalmodi commented Apr 9, 2022

Spec

Org note heading settings

Assume that user has kept the default value of org-log-note-headings.

Parsing state changes

:LOGBOOK:
- State "DONE"       from "DRAFT"      [2018-09-06 Thu 11:25]
- State "DRAFT"      from "TODO"       [2018-09-06 Thu 11:25]
- State "TODO"       from              [2018-09-06 Thu 11:25]
:END:

Above exports to this in TOML front-matter:

date = 2018-09-06T11:25:00-04:00
draft = false

Parsing notes added to LOGBOOK drawers using C-c C-z

: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.
- 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]].
- Note taken on [2018-09-06 Thu 11:45] \\
  Another note *bold* /italics/.
- Note taken on [2018-09-06 Thu 11:37] \\
  A note ~mono~.
- State "DONE"       from "DRAFT"      [2018-09-06 Thu 11:25]
- State "DRAFT"      from "TODO"       [2018-09-06 Thu 11:25]
- State "TODO"       from              [2018-09-06 Thu 11:25]
:END:

Above exports to this in TOML front-matter:

[logbook]
  [logbook._toplevel]
    [[logbook._toplevel.notes]]
      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._toplevel.notes]]
      timestamp = 2022-04-08T14:53:00+00:00
      note = """
  This note addition prompt shows up on typing the `C-c C-z` binding.
  See [Org Info: Drawers](https://orgmode.org/manual/Drawers.html "Emacs Lisp: (info \\"(org) Drawers\\")").
  """
    [[logbook._toplevel.notes]]
      timestamp = 2018-09-06T11:45:00+00:00
      note = "Another note **bold** _italics_."
    [[logbook._toplevel.notes]]
      timestamp = 2018-09-06T11:37:00+00:00
      note = "A note `mono`."

Note:

  1. The state change information does not get exported to the logbook. .. .notes table array.
  2. ❗ YAML export will not be supported.

@kaushalmodi kaushalmodi force-pushed the logbook branch 9 times, most recently from c4bcdcc to eae343f Compare May 9, 2022 15:19
TTA: TOML Table Array

TODO state change info in the logbooks doesn't get exported to
[[logbook_notes]].

Caveat: This feature works only if the `org-log-note-headings`
variable is left at its default value.
This commit is a small workaround to make the TOML generation for
`logbook_notes` to work on Emacs 26.3 as well.

The plist worked fine too, but only on Emacs 27+. Using plist gives a
runtime error in map-do/seq-do code on Emacs 26.3. See
https://lists.gnu.org/r/help-gnu-emacs/2022-05/msg00022.html for
reference.
Now the `notes` table array is nested inside the `logbook` table.
Don't assume that the LOGBOOK drawer name will always be named
"LOGBOOK".
v0.4.3 adds support for TOML table arrays in nested TOML tables, and
fixes the indentation when exporting multi-line TOML strings.
@kaushalmodi kaushalmodi marked this pull request as ready for review May 12, 2022 05:27
@kaushalmodi
Copy link
Owner Author

Improvements to this PR were added in #635.

@kaushalmodi kaushalmodi changed the title logbook content parsing feat: Parse date, lastmod and notes from LOGBOOK drawers May 12, 2022
kaushalmodi added a commit that referenced this pull request May 12, 2022
Hugo allows the presence `lastmod` and no `date` front-matter. In that
case, the `.Date` and `.Lastmod` both get set to the `lastmod`
front-matter value.

Ref: #504
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Read :LOGBOOK: drawer for metadata and modification timestamps
1 participant