I’ve created an action to save the content as a markdown file with the .md extension. That works well in the first phase, but when the Mac O/S file dialog pops up to save the file, .txt has been appended to the file name:
Want: my-nifty-markdown-file.md
Have: my-nifty-markdown-file.md.txt
I’ve tried a couple of different variations on the code, but nothing seems to work:
// clean file name
function cleanTitle(title) {
var clean = title.toLowerCase();
clean = clean.replace(/[^a-z0-9_\s]/g, '');
clean = clean.replace(/\s+/g, '-');
return clean;
}
// prompt for file name
var title = cleanTitle(draft.processTemplate("[[safe_title]]"));
var title_ext = title + ".md";
var p = Prompt.create();
p.title = "Save as...";
p.addTextField("fileName", "Name", title);
p.addButton("Export");
if (p.show()) {
var fileName = p.fieldValues["fileName"];
draft.setTemplateTag("file", fileName);
}
else {
context.cancel();
}