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

expand tinkr to reading metadata in toml? #126

Open
maelle opened this issue Dec 12, 2024 · 4 comments · May be fixed by #127
Open

expand tinkr to reading metadata in toml? #126

maelle opened this issue Dec 12, 2024 · 4 comments · May be fixed by #127

Comments

@maelle
Copy link
Member

maelle commented Dec 12, 2024

If the first line is "---" (or more I guess) it is YAML, if it is "+++" it is TOML.

The package wouldn't need to parse TOML, just to keep it as text to not break it.

Happy to make a PR.

@yabellini

@zkamvar
Copy link
Member

zkamvar commented Dec 12, 2024

Oh that's a good and simple addition! Go for it!

@maelle
Copy link
Member Author

maelle commented Dec 13, 2024

Should the change be a bit more ambitious:

  • renaming the current "yaml" to "front matter". It could be YAML, TOML, JSON, maybe something else.
  • adding a slot, or something else, to indicate the format of the front matter.
  • somehow deprecate the former "yaml" name, emitting a message if it is accessed. This reminds me of Deprecate components of output lists igraph/rigraph#1576

@zkamvar
Copy link
Member

zkamvar commented Dec 13, 2024

I think that's a great idea and R6 makes it really easy to do this with active bindings.

tink <- R6::R6Class("tink",
   public = list(
     body = NULL,
     front = "matter"
   ),
   active = list(
     yaml = function(yml) {
       message("oh no, we do not use this")
       if (!missing(yml)) self$front <- yml 
       self$front
     }
   )
 )

 n <- tink$new()
 n$yaml <- "---\nhey: there\n---"
#> oh no, we do not use this
 n$front
#> [1] "---\nhey: there\n---"
 n$yaml
#> oh no, we do not use this
#> [1] "---\nhey: there\n---"

Created on 2024-12-13 with reprex v2.1.1

@maelle
Copy link
Member Author

maelle commented Dec 13, 2024

Ok, thank you, I hope to work on this soon then! Or... next year 😸

@maelle maelle linked a pull request Dec 16, 2024 that will close this issue
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 a pull request may close this issue.

2 participants