Automate making quoted material italics

Does anyone have a suggestion on how to do the following in a large project:

For selected dialogue (currently delimited by quotation marks), change to italics. So, only text with the quotation marks would be changed to italic.

I would prefer to do this within Scrivener, but I realize I may have to export/import and do the changes with external programs/scripts.

Thanks,

I don’t know how to make this fully automatic (replace can’t add a character style), but you can use regular expressions to match text in quotes in Find, then simply use ⌘G to find next and ⌘I to make it italic, then rinse-repeat through the document.

The regular expression u(?:\.|[^\n"\])*(?=")[/u] is used like so (you will need to first convert all quotes to straight quotes in Transform menu):

You can play around with it live here, it would be possible to deal with smart quotes but it adds complexity. Also it won’t match quotes split across paragraphs as a safety measure:

regex101.com/r/v6oKFP/1 — Scrivener uses PCRE-like regexes…

The ability to REPLACE with a character style is on my wishlist for Scrivener V3.1, but until V3.0 is out no point in posting it — but that would fully automate this process…

And here is an external way: You could do this post-compile in Word, so long as the output used curly quotes. Using Word’s (full) search and replace fcn, you can search for arbitrary text enclosed in curly double-quotes, then set up the replace field with the code for found text, but with style set to italics.

gr

I just knew the Scrivener community would have a solution!

Many thanks nontroppo, this will work well for me. I thought of using regex’s in an external editor, but complicated regex’s like this are nearly beyond my capabilities. It is the finding and selecting manually that was tedious, this solves that, and I can decide if the selected quote should be italic–not all of them should be.

And thanks to gr as well. But I don’t have Word and a solution within Scrivener works better for me.

nontroppo:

FYI, this works well in combination with Keyboard Maestro to add a little more automation. However, the regular expression has a quirk:

When it encounters a paragraph like this:

“Where did that come from?” Jess asked. “I’ve missed that part of you.”

It first selects the words inside the first set of quotes: ‘Where did that come from?’ Then, when I used CMD-G the next selection is the unquoted ‘Jess asked.’ The next CMD-G selects the last quote, ‘I’ve missed that part of you.’

This doesn’t affect the usefulness of this method–I am verifying each quote needs to be converted as I go. Just a strangeness of the regex.

Thanks again.

(And now I also know where pigfender got his plot idea for NiaD 2017 from. :wink: )