Is there a formalism for bracketing text that is not to be printed?

In programming, there is a convention of using “–” to “comment” text within code to be ignored by the compiler or runtime interpreter.

Is there a way to bracket a string within a Scrivener document such that Scrivener knows not to include the string when exporting (compiling)?

I am presently accomplishing this by declaring such non-printed strings as “inline annotations”, but this method is visually jarring.

Thanks, Randall

1 Like

You can accomplish this with the Replacements function of Compile. You can specify a replacement in the third column of the main compile dialog box, or can specify replacement within a particular compile setting.

You will need to craft a regex expression to target a unique bracketing of your choice and leave the to-replace-with field empty.

When I get back to my mac I will look up the regex I use.

gr

Thanks. Any help would be appreciated.

I am thinking that Scrivener’s “Inline Annotations” function would be perfect if one could adjust Inline Annotation presentation style and color in the “Appearance” pane of Scrivener Preferences.

Inline annotations can each have their colour changed individually. Some prefer to use this as a way of colour-coding different types of comments (I use light grey for deleted text, bright red for important notes I absolutely do not want to scroll past without seeing, etc.). As with the text highlight feature, the preference is saved automatically whenever you change colours.

So of course one way of reducing the visual impact of annotations is to select a less notable colour, maybe even to use black so that all you’re really working with is the bubble.

Secondly, there is a setting in the Editing: Options preference pane, Do not color the text of inline annotations. This will leave the text alone, leaving the colour for the outline itself, and a very subtle background tint. Some prefer this look for its aesthetics as well as the performance boost on older systems. Since the text colour is left alone, very pale colours can be used, leaving the bubble barely visible even.

If that’s not good enough, then know that Styles also have the capacity to become comments. Styles can of course be as subtle as you want them to be, and also have the advantage of the capacity for multiple types of comment streams, which some do prefer. Styled text can be deleted by the compiler by adjusting the Format you use, so that the style is added to its Styles pane, with the instruction to Delete text of this style, in the right-hand settings area.

Replacements, so that one has an actual comment syntax like in programming, is also totally viable with Scrivener. That can be useful if you are bringing in source material from plain-text workflows that use such mechanisms (like HTML comments in Markdown documents).

A simple one like prefixing a line with “–” would be an easy one to solve with regex. Try copying and pasting the following into your Replacements table (this considers the space after the dashes to be a part of the syntax—and naturally you’re going to want to switch smart dashes off in Edit ▸ Substitutions):

<Replacements> <Replacement RegEx="Yes"> <Replace><![CDATA[^--\s.*\n]]></Replace> <With><![CDATA[]]></With> </Replacement> </Replacements>