Finally, I got this to work.
Thanks to @gino_m and @holroy for sharing their excellent ideas and providing potential solutions.
What it works consistently is using templater to execute the JavaScript code and generate the transclusions for the callouts inside the new note that templater creates.
I am using this template to make collections of the best paper extracts that I put on inside callout blocks. Obsidian doesn’t have direct support of callouts as in headings, lists and tasks, so one has to do it from scratch.
While reading papers I extract the best lines, paragraphs, plots, tables, or equations and put them inside a callout with a title and a heading. I have three quality categories: gold, silver and bronze. Instead of creating a new callout I use existing ones such as “award”, “sun”, and “rocket”. I believe they come with the plugin Callout Manager. Since every paper has its own note that are located under the folder Sources
, I read their data from there. A paper source note may have one, two or more than ten callouts, but only one can be gold, and silver, and bronze. Of course, the paper source note has several sections such as Critique, Highlights, Extracts, Mechanisms, Citation, References, Glossary, and the PDF paper Preview. The section that has the callouts is Extracts.
What the template does is iterating through the pages under the folder Sources
, then iterate through all the callouts, and then only extract the callout that is labeled as “award” (gold), “sun” (silver), or “rocket” (bronze). The callout label, title, and block-id are extracted through the array match
. Then, each of the callout blocks is transcluded with tR += "![[" + page.file.name + "#" + match[4] + "]]"
. Here the variable tR
is acting like a print statement inside templater. The final note contains all the transclusions from all the papers in one place. You can name the note whatever you want. I use something like “Gold callouts”, etc.
I think this is a better and more stable solution that doing the transclusion directly using dataviewjs
. DVJ works sometimes, and is very fragile, as in showing the code instead of the transclusion.
<%*
const dv = app.plugins.plugins.dataview.api
const pages = dv.pages('"Sources"') // folder
const regex = />\s\[\!(\w+)\]\s(.+?)((\n>\s.*?)*)\n/ // callout
const blockID = /((\^)([0-9a-z]{6}))/g // block-id
// iterate through notes
for (const page of pages) {
const file = app.vault.getAbstractFileByPath(page.file.path)
// Read the file contents
const contents = await app.vault.read(file)
// Extract the callouts via regex
for (const callout of contents.match(new RegExp(regex, 'sg')) || [] ) {
// on each callout read the type, title, and block-id
const match = callout.match(new RegExp(regex, 's'))
if (match[1] == "award") { // callout for Gold
match[2] = match[2].split("#")[match[2].split("#").length-1].trim() // title
match[4] = match[3].match(blockID) // block-id
tR += "[[" + page.file.name + "]]" // link to note
tR += "\n"
// transclusion to content of whole callout
tR += "![[" + page.file.name + "#" + match[4] + "]]"
tR += "\n\n"
}
}
}
%>
This is an example of the callout labeled as Gold:
> [!award] ### Numerical results on the BDR mechanism
> Numerical results showed that the [MBDR](Bubble%20Drag%20Reduction.md) mechanism can be attributed to the following three factors:
> 1. An **additional momentum source** is caused due to the injection of gas bubbles. This redistributes the flow structure of the carrier phase in the boundary layer and reduces the resultant skin-friction coefficient along the wall surface by increasing the normal flow velocity, leading to a significant decrease in the mean stream-wise velocities.
> 2. The presence of the micro-bubbles **causes perceptible turbulence modification** to the carrier phase. Turbulence attenuation occurring near the wall surface may contribute to drag reduction.
> 3. The injection of microbubbles **creates a thin film of liquid that covers the wall surface**, thereby reducing the shear stress and drag forces between water and wall.
> ^gnt6kf
It is key to add the block-id to the callout. That is how the script makes the transclusion possible.
Enjoy!