One particular use case / workflow that I am trying to set up in Notenik is to write up the release notes for a product (a new note for every new version). I have the template set up to capture all required metadata etc and that side of things is working nicely.
I need to be able to export a (release) note in 2 formats - one that populates a markdown document (that i will pull into my blog) and another that populates an xml file (that will be used for the product update process). I had thought that using the ‘Reports’ option would give me what I need but i am running into a couple of issues:
- The report seems to generate for all notes. Is there a way to restrict this to only the note(s) selected?
- When the report runs the content is presented in the Query window and if i select to save to disk there is a default file name of
query-output.html as opposed to generating the file specified with the output command in the template.
Am i doing something wrong here or are reports not what i should be using?
Any advice appreciated.
What you want to do is write/generate your own script, and then run it, all using the Scripter window. I probably need to do a video one day on how to use this. It’s a bit tricky.
OK - thanks for that @hbowie
Before I go down a rabbit hole with scripting can you confirm that I am able to apply the script to only a single note (or to selected notes)? Would that be in the filter module that I can set that condition somehow?
Yes, you can filter on any field. Although maybe it would be good for me to add a template option in the Share command, if you really only want to format one note at a time…?
So i’d have to tweak the script to specify the note i want to export each time (i.e.
seq = 1.3.1 etc?). Or is there was a way to filter for the max value of seq (or a similar approach)? An additional filter option for
selectedNotes would be useful perhaps?
Or, as you say, an option in Share to utilise a template.
See the 12.8.6 beta and let me know if this scratches the itch.
That works great! Many thanks indeed for the addition @hbowie. I have tested successfully with both the markdown and xml templates that I mentioned above.
One enhancement that I would really like to see if at all possible, is the option of specifying the file name in the template somehow (if not the full output path). At the minute I manually have to amend the title as it defaults to
note-title.md which is neither the title nor the file type that I want.
@oddballs, I just did a little test, and even though I say not to use the output command in the template, it looks like an output command will work. Do you want to give that a try and let me know how it goes?
The other thing I guess I could do would be to use the filename specified in the output command as the default starting filename when writing an output file via the Share w/Options normal mechanism.
Ah - you are right. It does work! And by selecting ‘Copy to clipboard’ as the destination i am not presented with the file save dialog. I think this will suffice just fine. Thanks @hbowie
Trying to build on this to create working templates and have hit an issue in that the template doesn’t seem to process the IF command. An example:
<?if =$build$= > 100 ?>
Outputs the following in the produced file:
<?if 119 > 100 ?>
Am I missing something?
@oddballs: I couldn’t reproduce your problem.
See attached for the little test I put together.
if_tests.zip (4.9 KB)
Thanks for passing that on. Your demo worked for me too and comparing your setup and mine revealed no huge difference EXCEPT that my IF statements were all inset in my (xml) file by 4 spaces. It seems that not only do they need to be on a new line, they also need to be at the start of that new line! Lesson learned
I’ll update the Knowledge Base to make it clear that merge commands must start in the first positions of their lines! Sorry that wasn’t clear before! Thanks for pointing this out!
I should put this in the Feature request section but…is there scope for a future version to allow merge commands to be used inline? It would offer more options for what can be done with them. A simple example off the top of my head:
<div class="<?if =$importance$= > 8 ?>important<?endif?>">...</div>
(and i know there are ways that i could achieve this particular example with the current set up but it is merely meant to illustrate the point)
I’ll add it to the list! It’s certainly a possibility! (But probably don’t look for it anytime soon…)