[Request] include $text for blocks
With list-items there is a key '$text' that contains the contents of the item. Are there any plans to also include such a key for blocks in datacore?
I think I read somewhere in a release that pulling the text content into indexes was actually being avoided for the most part, but that tasks aka list items were a common enough use-case for an exception to that.
I’d still be interested to see if there’s some workaround to display a block’s content since they lack a $text property.
im curious - if datacore has a reference to the block itself if we can somehow use that information with the obsidian api to pull in the markdown for that block (or section, in my case)
I would love to be able to query section content:
# Notes
here is a note i would like to see in a dataview query somewhere
and it could be multiple lines!
@blacksmithgu any thoughts on how we can approach this?
Just a note on this: Datacore provides the line numbers for most of the sub page types with the $position property .start and .end, which can then be used to pull the contents using the obsidian api. I wrote a function for this for my own use, here.
static async loadFileContentBetweenLines(filepath, startLine, endLine) {
let file = app.vault.getFileByPath(filepath);
try {
const fullContent = await app.vault.read(file);
const lines = fullContent.split('\n');
const actualEndIndex = Math.min(endLine, lines.length);
const selectedLines = lines.slice(startLine, actualEndIndex);
//join and make sure there aren't leading or trailing characters
return selectedLines.join('\n').trim();
} catch (error) {
console.error(`Error reading file or extracting lines from ${file.path}:`, error);
return null;
}
}