Is there someone who has developed a Timestamp that can be applied to a note that will export it as markdown and convert selected attributes to valid YAML properties in the exported .md file?
I would be very grateful to have an example to work from as I want to be confident that I can export my zettelkasten atomic notes back into the markdown world.
One area I am most confused about is the application of templates. Just how do they work? How the template would be/is constructed to do this?
I think the key point of the template is that everything except the export code will be output as is.
I created a sample file, so please use it as a reference.
I don’t use Obsidian. So, please adjust the finer details as needed. MarkdownWithYML.tbx (136.2 KB)
When you want to export as Markdown, you need to make $Markdown true and don’t use ^text^.
#tMarkdown
---
created: ^value($CreatedDate)^
tags: [^value($MyString.replace(";",",").replace(",$",""))^]
---
^value($Text)^ # <- with no html tag.
I use replace to separate $Tags with commas. If the last comma doesn’t cause any issues, the second replace is unnecessary.
To avoid the issue of .replace() and a hanging comma on ex-list data, use .format(), see list.format(formatStr). Essentially, the format string you provide is added between each source list value and the whole is returned to the current expression as a single string.
Thank you for letting me know.
It has become much simpler.
#tMarkdown
---
created: ^value($CreatedDate)^
tags: [^value($Tags.format(","))^] # <- $MyString is incorrect in first post.
---
^value($Text)^ # <- with no html tag.
Here’s one of my cases for exporting markdown to Obsidian, including YAML frontmatter (AKA Properties in Obsidian).
I inventory incoming books using BookBuddy, which is relevant because it scans the book’s barcode then snarfs data from public databases based on ISBN code. From BookBuddy, I export book data to .csv and drag the .csv file into my Tinderbox book inventory document. A Book prototype is automatically applied there on import, and that prototype assigns my BookNote template to the imported note.
The BookNote template formats the data for export to Obsidian as .md files. Here’s the template
---
ReadStatus:
Title: "^value($Name)^"
Pages: ^value($Number_of_Pages)^
Publisher: "^value($Publisher)^"
PublishedYear: ^value($Year_Published)^
PublishedPlace: ^if($Place_of_Publication) "^value($Place_of_Publication)^" ^else^ NA ^endIf^
ISBN: ^value($ISBN)^
Inventory: [[^value($Created.format("y-M0-D w"))^]]
Platform: ^value($Platform)
---
# ^value($Name)^
Readwise: [[Reading/Readwise/Books/^value($Name)^]]
Subtitle:: ^if($Subtitle) "^value($Subtitle)^" ^else^ NA ^endIf^
Author:: [[Reading/Authors/^value($Author)^]]
Genre:: ^if($Genre) [[Reading/Genres/^value($Genre)^]] ^else^ "" ^endIf^
## Summary
^value($Summary)^
# Reading Status
` ` `dataview
TABLE without ID file.link as "Date Recorded", ReadingHours as "Hours", ReadingSection as "Section", ReadingComment as "Comment"
WHERE Reading = [[Reading/Readwise/Books/^value($Name)^]]
SORT file.link
` ` `
# Book Notes
![[Reading/Readwise/Books/^value($Name)^]]
Note:
the triple backticks around the dataview inline code have excess spaces because Discourse is weird
I import highlights to Obs, so that’s why the code has links to Readwise folders and articles
The inline properties (e.g., Subtitle::) could have been included in the YAML frontmatter. Purely an operational choice.
$Summary is an import by BookBuddy from the publishers’ book blurbs, that and all the other Tinderbox attributes are populated by the .csv import process into Tinderbox. (The exception is $Platform where I track hardcover, softcover, and e-book sources.)
Wow! What a great community! And thanks to each for examples which I am now reverse engineering with little adjustments to learn how it all works. Templates, for me, have always been a bit of voodoo that I didn’t understand at all. This work through is certainly helping me.
P.S. I would/should have brought this up in the Tinderbox Meetup, but I am on a MacMini with no camera and microphone. Therefore I am just a mute observer of these events.
I know export code doesn’t require a closing code as Tinderbox parses the end of an export code, e.g. ^value($Name) and ^value($Name)^ are functionally the same.
But, by using a closing caret, i.e. ^value($Name)^, makes it easier to see what gets injected into the HTML (or other format) output. Thus for note with the name ‘Demo’, the template code ^value($Name)^ on output becomes Demo.
One way to find your way into understanding templates is to start with template code copied from the source an actual working file elsewhere, i.e. with no Tinderbox export at all. Then find each bit of the template where the existing text needed to be a value drawn from your TBX’s data. That can be more helpful than trying to write a template starting with no code at all. It’s something I tried out when first exploring export and still use it occasionally—especially when what I thought I coded correctly appears not to work as envisaged.