Transclude linked draft but omit first line

Inspired by the “omit first line” option in the New Draft With Template action, I’m looking for a way to transclude a linked draft while omitting its first line.

I thought of customizing the transclusion actions in the Examples: Cross-Linking action group.

Something like:

[[b:Title of Draft]]

(“b” for “body”)

Or even something like specifying a starting line number, like:

[[Title of Draft|x]]

… where xis the first line to include.

However:

  • This might already be possible in some way I’m not seeing/understanding
  • There may be a better/easier way I’m not thinking of
  • My technical skill is… shall we say, “limited.” (I could probably do it, but it would take way longer than I should spend doing it.)

I’d be grateful for any suggestions.

Are you needing a different syntax to markup those items because you sometimes want to include only the body and sometimes want to include the whole thing?

If you just want to modify the transclude example to always use the body instead, that is easy. this is the function within those actions modified to only insert the body - only one line is changed:

let transclude = (d) => {
	let re = /\[\[(.+?)\]\]/gm;
	let content = draft.content;

	content = content.replace(re, (match, title) => {
		let d = findLinkedDraft(title);
		if (d) {
			// return d.content; <- comment out existing line
			// add line below to only return body...
			return d.processTemplate("[[body]]");
		}
		else { // not found, leave as-is
			return match;
		}
	});
	return content;
}

Thank you for that!

I can make having two versions of the transclusion action work.

I imagine there’s a way to add a sniff for a pre-pended string like b:, and switch based on that.

Probably a good :v:t2:“learning experience”:v:t2: for me. :roll_eyes:

Thanks again!