This may be too specific to my use, but maybe someone generous may be willing to help.
When I used FoldingText, there was a great plugin for filtering structured Markdown by search terms–like, show me only content under headings with “XXX” in the name. I used this for structuring feedback to students. I would have content like this:
# Assignment 1
## Draft 1
### Billy
great paper
### Johnny
bad paper
## Draft 2
### Billy
bad paper
### Johnny
good paper
Then, I could filter and say, show me only the feedback I gave Billy.
I’d like to recreate that in Drafts. I am 80% of the way there with the following script:
// Student filter
let [loc, len] = editor.getSelectedLineRange(),
str = editor.getTextInRange(loc, len),
regex = /### /;
;
let split = str.split(/r?\n/,2);
let stu = split[0].trim();
stu = stu.replace(regex,"");
const fullContent = draft.content;
const fullStudent = fullContent.split('### ');
let student = "";
for (s in fullStudent)
{
if (fullStudent[s].includes(stu))
{
student+=fullStudent[s] + "\n\n"
}
}
draft.setTemplateTag("student", student);
(In this script I don’t supply a search term, I just put the cursor on the line of the student I want to filter by and run the action.) After the script step, the “student” tag is sent to an HTML preview action.
However, what I don’t see here are the level 1 and 2 headings, which tell me the name of the assignment and draft version. In other words, I see:
Billy
great paper
Billy
bad paper
But what I want to see is this:
Assignment 1
Draft 1
Billy
great paper
Draft 2
Billy
bad paper
How can I adjust my script to show those headings?
Thanks for any help!!!