Converting straight to smart quotes

I know that converting straight to smart quotes is difficult, because of unpaired examples etc etc, but some apps (Marked 2, for example) do it brilliantly. I need to convert straight to smart in the body of a Markdown document (but NOT in the YAML) and I thought I could do that by exporting from Marked2 to Markdown, but it seems to re-straighten the quotes when it does that.

So then I thought maybe someone has done the heavy logic in something like Applescript, and I could copy the body and run it through that. I cannot seem to find anything like that. Anyone have any pointers?

I know about TextSoap, but even with the current discount it does seem kinda expensive, given that I don’t really need to do a whole lot of this sort of cleanup.



You can split your YAML from the remaining content relatively easily then to process the quotes, a quick Google yielded something from @drdrang that looks like it would do the processing you asked for. Then recombine and replace.

Thanks for the link to @drdrang. That provides a great example for building a little something (probably in Python) that I can call with Alfred. Not for a couple of days, because I am currently snowed under and it really isn’t that big a deal, but a good, manageable project for when I have a bit of free time.

I don’t want to discourage you from a spot of coding (far from it), but you can just drop it into a shortcut and use it as a quick action. You could then whip up a workflow with a Universal Action trigger for a file which then calls the shortcut (latest version of Alfred has direct support for this. Using that approach, you can utilise it easily both within and outside of Alfred.

Just an option.

Too late now. :smiley:

I went ahead and made two versions, in Python. One is standalone. Paste something multiline as input and it returns (via the Mac clipboard) a smartified text. (How do I remind users that they can use CRTL-d to end the input?) I’ve yet to see how best to automate that, but I suspect I will in any case use the other one most of the time.

The other is specifically designed to work with Alfred, and takes the selected text, smartifies it, and pastes it straight back. Bingo.

It is important to me not to act on the whole file, because I need straight quotes in the YAML. I suppose I could ignore everything between the markers, but this seemed simpler.

Thanks for your help.

For what it’s worth, the above Shortcut does keep the YAML intact; but it is designed to work on the file rather than text in a currently open file in an unknown/arbitrary (i.e. current) app.