Transforming text case in compile question

Does anyone know of a way to create a compile setting that will take a character style such as “Emphasis - Speaking” and transform the styled text into all uppercase?

My use case is that I do readings of my work, and I have a few character styles set up in scrivener related to vocal inflection that I only use when I compile for a reading; they are otherwise invisible when I compile for normal publication.

Transforming a style to bold, underline and the like is easy enough. It is not immediately obvious to me how to transform tagged text to uppercase in compile, or if this is even possible. Any input appreciated!

Scrivener itself is very close to being able to do that, but it can’t quite do it. It would involve the use of Replacements, and its support for the more advanced regular expression syntax, which in some implementations is capable of transforming letter case. Unfortunately the Mac regex engine does not support that extension!

However Scrivener as a citizen of the larger macOS operating system can do this. It does involve integration with the UNIX side of the system; I don’t know how comfortable you are with that. Here is a recent thread that goes over a very similar problem, and how it was solved.

What would need to be added to that approach is the use of style prefix and suffixes, in the Styles compile format pane. By enclosing the text you wish to uppercase in some kind of textual marking, that would be your way of signalling to the post-processing script what parts of the text you want to have transformed, as well as to have it strip out the markings.

That’s how I would do it anyway—though I’d entirely understand if after having looked through that, you’re happier with an answer of “no, it doesn’t do that”. :wink:

It would probably be easier to do any or all of the following than to try to transform the text to upper case: Increase the font size, change the color, add brackets around the text, add emoji or other special characters in front of or around the text, underline, change the font to something that looks upper-case-ish…

Thanks so much for the help. That all makes perfect sense, and confirmed my suspicions. Scrivener is such a deep program that I always feel I may be missing something.

Yeah, speaking of which, depending on your font, you might be able to solve this with typographic adjustments. For example with the Libertine font (pictured below), you can modify both the Upper Case and Lower Case glyphs to use “small capitals”. Ordinarily one would use a tool like this to switch only the lower case glyphs to small capitals, for title casing and such, but this font allows both upper and lower case handling.

[size=80]Typographic features are added to the style during the compile phase, and the text colour is stripped out.[/size]

This would produce a subjectively nicer looking copy than actual all cap text in the middle of a paragraph, in that it would still have that sharp distinction to draw the eye to it, but without producing the dominating character glyphs that tower over regular text—same reason you’d often want to use small capital glyphs for acronyms.

The downside is that not every word processor out there is as sophisticated as the macOS text engine where it comes to advanced typographic features (and some that are use their own proprietary codes that don’t map to standards). Either way, the effect can get lost in translation if you use something like .docx to share copies that might get converted or passed through unknown editors. PDF works fine of course, as does RTF on a Mac and maybe elsewhere.