I write Markdown notes often starting with something like this
Base Header Level: 2
CSS: /_resources/default.css
# Note about finding the first H1 line
.
.
.
When I want to send this Draft to Devonthink or iA Writer or any other Notetaking app I need to specify a title for the note.
As title I would like to use just the text in the first H1 line (here “Note about finding the first H1 line”), but what is the easiest way to extract it from the Drafts object?
Drafts tends to think about the first line as the title. While you could extract any line and use it, I would tend to suggest it would be best to just use the title in the first line in Drafts and let your action re-organize the text. For example, write like:
# Note about finding the first H1 line
.Base Header Level: 2
CSS: /_resources/default.css
.
.
Then, when outputting in an action template, you [[display_title]] to get the title and [[body]] for the remaining text to send off to another app.
Just another idea…
do you alwys use the same settings like in your examples like:
for the drafts you want to send to DEVONthink?
or do you have “set” of CSS / header levels that you use?
If you don’t need the metadata in the Draft, then you can write the draft without these lines in the first place. then use the standard template tags like agiletortoise suggested and just add those lines below the title.
Example draft:
# title
. some
. notes
. here
the script could do the following steps:
get the relevant templates (e.g. [[display_title]] and [[body]]
[optional] display a prompt to select the metadata (base header level and CSS)
modify the body of the draft to
.Base Header Level: [selected level]
CSS: [selected css file]
. some
. notes
. here
update the draft / body content
use the url scheme of DEVONthink to pass the text over
Well, modifiying the body is what I would like to do, if I follow @agiletortoise’s idea:
In the first line I have the title, so the action than needs to find the first H1 line (which can be on an unknown line) and add there the text from the title. How can I modify the body like this? (I’m a bit of a newbie in tehse regards…)