Tinderbox Training Video 31 - Integrating Export Code & Action Code in Your Text

Twisting the ideas in this thread a little further, I’m trying to turn the concepts into a Table of Contents to be exported in Markdown format, incorporating links to the actual header.

E.g. I export a note with children to a markdown file, and at the top of the file there’s a TOC with clickable links to the child sections (which have to be in the format [Heading name](#heading-name))

Using the code in this thread so far, I have:

^value((collect(descendants(this),"[" +$Name+"](#"+$Name.lowercase.replace(" ","-")+")")).unique.format("","- ","\n",""))^

This produces:

- "[Daily Notes](#daily-notes)"

- "[Markdown image links redux](#markdown-image-links-redux)"

- "[Another note](#another-note)"

As you can see, the problem is that it surrounds each line with unwanted quotation marks, and I can’t see where they’re coming from.

If I replace the string concatenation with $Name on its own, there are no quotation marks and it turns out as expected:

^value((collect(descendants(this),$Name)).unique.format("","- ","\n",""))^

-->

- Daily Notes
- Markdown image links redux
- Another note

If I take the concatenation out of the action code and preset it into a calculated attribute ($TOCtitle), so the collect is calling an simple attribute rather than constructing the string on the fly, I still get the unnecessary quotation marks — so why is this different from calling another string $Name?

I must be missing something obvious, but I can’t see what it is…

Thanks for any help (and thanks very much for all the great ideas in the thread so far. It’s expanded my knowledge and ambitions hugely…)