InsertText not respecting Smart Quotes/Dashes setting?

Hi there,

I’ve disabled the Smart Quotes and Smart Dashes autocorrect options for the Markdown syntax in Drafts, because they affect YAML front matter. This is fine in the editor itself, but when I run an Action including an insertText script step, the inserted text seems to nevertheless be processed by the Smart Quotes and Smart Dashes replacement system.

A trivial example follows. First, ensure that Smart Quotes and Smart Dashes are disabled in Drafts’ settings for the current syntax. Then, create an Action with an Insert Text script step, which inserts the following text:

title: "[[title]]"

When the Action is run (at least on my machine), the text inserted into the frontmost draft will have smart/curly quotes, and the triple-dashes will each become an em-dash plus a regular dash.

My feeling is that, if the user has disabled Smart Quotes and Smart Dashes, this should be respected for all incoming text regardless of its provenance.

Fun. UITextView is pretty proud of its “smart” features even when you’ve disabled them. I believe I had to workaround a similar issue pasting text a while back…will take a look.


Similar issue here - I use “Insert Text” to format .csv output which requires some straight quotes. However, in spite of using a Plain Text draft with Smart Quotes DISABLED, my straight quotes are returned as Smart Quotes, which plays havoc when I import .csv file into Excel. My current workflow therefore requires a Search/Replace before I export.

I have also tried to use the Straight Quotes Action to do the conversion, without success.

Any ideas out there?

Thanks in advance,

Could you provide an example action demonstrating what you are doing? “Insert Text” is really intended only for use as the type of function that inserts text in the editor - like a key that inserts a date.

You may be running into a bug, and I’d like to see that in action, but it’s also likely it’s not a good way to prepare text for output manipulating it in the editor and there might be a better/more reliable way.

Wow - thanks for the quick response! I am not used to that kind of support from other developers!!

OK - in the process of documenting my “issue”, I realized it was my mistake after all (sorry about that) - one of the first INSERT TEXT actions I created, inadvertently inserted literal smart quotes (not sure how to even enter those, but at that point, I was probably still using markdown mode instead of plain text and didn’t have smart quote conversion disabled, so maybe that is why smart quotes were entered?). Anyway, I now changed the smart quote literals to straight quote literals and all is good now.

I am new to Drafts and it has been awhile since I did any coding, so I would like to briefly explain how I am using the INSERT TEXT action to see if you think it is an inappropriate use or if there is a better way to do it.

The use case is a front-end data capture for a Time Tracking application I have setup in Airtable (the eventual goal is to update directly into Airtable, but not until I get this method down first). At the end of a day I export a .csv file from Drafts and then use Excel to reformat the data for import into Airtable. I really want to optimize this process first, because I have several other use cases that don’t end up in Airtable. I have included below a screen shot with a bunch of scribbling, but the basics are as follows:

In the Action Bar, I have several actions to assist in entering time and details:

NewDay - creates new draft, assigns “time” tag, involks another action that uses TextExpander to create the top two lines (Title and Date Stamp) and the 3rd line, which is the first entry for the day

Start - creates a new time entry (Time Stamp, [], “”") - note the trailing double quotes, which will wrap the 3rd DESCRIPTION field to allow special characters without interfering with the comma delimiters

CC-TXT - insert any of several activity types within the preceding square brackets (these ultimately create a multiselect array field in Airtable (EmailFrom, TelconTo, LeftMessage, etc)

Mic - allows for dictating the Description field, which I mostly use remotely with my iPhone; if in the office, I use my iPad with the Magic Keyboard (pretty awesome)

End - inserts the closing double quotes, final comma and ending time stamp

Dropbox - exports the draft to Dropbox

Last, if it would be helpful to upload my ActionGroup, I would be glad to do that, but not quite sure how to do that at this point.

My apologies for the long post, but thanks in advance for any insight you might offer.

Best Regards,

Sorry to resurrect on an old thread, but this is exactly what’s happening to me with an action.

Script to paste text from clipboard:

 // See online documentation for examples

 let str = app.getClipboard();

 let result = ‘This is a test for “smart quotes” getting inserted from the clipboard: ‘ + str;


Sample sent to clip board: Lorem ipsum dolor sit amet...

Script results:

This is a test for “smart quotes” getting inserted from the clipboard: Lorem ipsum dolor sit amet…

Note the result has “smart quotes”, even thought I have smart quotes turned off in Settings.

This is occurring on my iPad Pro on iOS 15.6.1 with Drafts 32 + Pro subscription.

Let me know if you need any other details.

LOL… even pasting into the forum formatted my quotes as smart quotes. Here’s a screen shot of the action in Drafts.

That is expected behavior. The editor “smart quotes” feature is a system-level feature that tries to look for and modifies straight quotes and convert them to smart quote as you type. It does not, in any way, attempt to do the opposite and remove smart quotes you explicitly type or enter.

If you have text with smart quotes which you want to remove them from, use an action to straighten them

The problem I’m running into is the action is pasting in smart quoted text that came from an Action that I thought should have been straight quotes.

If I have a text string to be inserted as part of an Action, and the text in the Action editor appears to be straight quotes, shouldn’t the action respect the straight quotes in the editor and paste straight quotes again?

Using editor methods behaves similarly to typing…not entirely, but similarly, because it’s calling underlying methods on Apple’s text control and it will, in many cases, apply some of the features to the text.

Not sure what your overall goals are here…if you want to avoid editor side effects, you can manipulate the draft content directly in your script.

Or, of course, disable smart quotes, so the system does not mess with your text.

Thanks for the follow up. That cleared up my misunderstandings of the Action. :+1: