Is there a way to filter out any text that is striked out? I have a query that pulls any data under a specific heading but would like to not pull those with strikethrough formatting.
Some regex could help. I donāt know about your table, but you can include a regex ānot matchā; something like this:
```dataview
TABLE
FROM [[Your File]]
WHERE !match(file.content, /\~\~(.*?)\~\~/gm)
What are you going to do with the filtered text?
Are you already using a variant over the script AlanG has shared around here? If the latter, then you could possibly do a regexreplace on the strikethrough text before presenting the text to the user.
I was on my phone when I posted but would like to post the variations and error results I have unsuccessfully tried for any insights.
What I am doing is looking for any text under the āThoughts and Notesā subsection which is where I place items that donāt rise to a task/todo level, or are fleeting thoughts, etc. As they are in my daily notes but not referenced easily, I am trying to make a single page where these are gathered so I donāt forget. If the note getās moved, then obviously itās not in the subsection anymore but others, I want to keep around just in case for now so I strikeout the text. As I work through the process of building my PKM, I may simply just delete them.
TABLE L.text AS "Thoughts and Notes"
FROM "01_Daily_Notes"
FLATTEN file.lists AS L
WHERE meta(L.section).subpath = "Thoughts and Notes"
WHERE !match(file.content, /~\~(.*?)\~\~/gm)
TABLE L.text AS "Thoughts and Notes"
FROM "01_Daily_Notes"
FLATTEN file.lists AS L
WHERE meta(L.section).subpath = "Thoughts and Notes"
WHERE NOT meta(L.text).(file.content, /~\~(.*?)\~\~/gm)
TABLE L.text AS "Thoughts and Notes"
FROM "01_Daily_Notes"
FLATTEN file.lists AS L
WHERE meta(L.section).subpath = "Thoughts and Notes"
WHERE NOT file.content.contains("~~")
Did you manage to sort it out?
I am a not a DV expert and just dip my toes in scripting as well and Iām more comfortable with DVJs, for some reason. All my queries on my dashboard canvas are DVJs queries.
I couldnāt get the subpath to work in DVJs so I cooked with the ingredients I had. I also didnāt work with the advice given above, as I simply deleted the text within pairs of ~~
(the original text in the files remain in place):
```dataviewjs
// Define path
const queryPath = /01_Daily_Notes/;
// Query all pages
const allPages = dv.pages("");
// Filter pages to be queried
const filteredPages = allPages.filter(page => {
const path = page.file.path;
return queryPath.test(path);
});
// Crawl the raw data content and filter pages based on given criteria
const pages = await Promise.all(
filteredPages.map(async (page) => {
const content = await dv.io.load(page.file.path);
const subpathRegex = /##\s*Thoughts\sand\sNotes([\s\S]*?)#{1,6}\s/gm;
const matchSubpath = content.match(subpathRegex);
if (matchSubpath) {
const filterPattern = /~~(.*?)~~/gm;
const filteredContent = matchSubpath[0].replace(filterPattern, '');
return {
link: page.file.link,
content: filteredContent
};
}
return null;
})
);
// Remove null entries and render the result table
const filteredAndProcessedPages = pages.filter(p => p !== null);
dv.table(
["Thoughts and notes", "Content"],
filteredAndProcessedPages.map(p => [p.link, p.content])
);
```
- The above expects any heading to come after level Thoughts and Notes, though.
Or you can change/##\s*Thoughts\sand\sNotes([\s\S]*?)#{1,6}\s/gm
to something else to better target the text to be manipulated or maybe you can get subpath to work.
Also, the lines need to be separated as they are currently merged in the table. Changingconst filteredContent = matchSubpath[0].replace(filterPattern, '');
toconst filteredContent = matchSubpath[0].replace(filterPattern, '\n\n');
didnāt help. There is some way to separate them as I saw this issue before but it eludes me.
You got it! Thanks!!!
As I said, this is a workaround, not the solution. Iād be interested in the Solution myself.
Funny cause to me this is a great solution.
Simple enough, though. Change it to const filteredContent = matchSubpath[0].replace(filterPattern, '<br><br>');
and voila.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.