Hi.
In a project I am currently working on, there is a place where I censor a cursing passage.
I’d like to do it comic-strip style :
%$@&#!!
These are just symbols, and are treated as such.
Is there a way for them to be together treated as a word in the compiled output, so that they don’t get split across two lines ?
Any ideas welcome. Thanks.
[EDIT] Creating a screenshot to make myself clearer, I just realized that only the % symbol seems to cause a problem… Perhaps, not using %, it works just fine after all.
It looks like you have a solution for now, but for future reference: this is what the Insert ▸ Break ▸ Word Joiner character is for. Position the cursor between the symbols or characters that shouldn’t break lines, and use that command. It’s a truly invisible character, no space is added, but you’ll see where it is if you cursor through the area—you will note the cursor gets “stuck” when passing by it.
I knew I had seen something like that somewhere in the menus, but I thought it to rather just be a special non-breaking " - ". Not something invisible (which would have been perfect, should my thing be still not working).
Good to know.
Thanks Amber.
Have you tried compiling a paragraph’s worth of your “censored” text to whatever formats you’re aiming for? Just because Scrivener keeps a series of non-word characters together doesn’t mean that e-book readers will, for instance.
That would indeed be the next logical step. Thanks.
Hopefully, if it doesn’t, AmbersV’s solution will fix that ; or there is an alike coding solution.
As to what different Ereaders might do of it (especially android ones) I have no clue at the moment.
P.S. There are, however, in the above Sigil’s screenshots, these two & and & after the % symbol that was previously problematic… (In both lines 1 and 2, word-joiner or not.) Perhaps that is some sort of compensation. (?)
No doubt every other text editor and viewer is going to have different punctuation marked as “weak” points in a string to break on.
I’m also not sure if the Unicode character this command inserts has any meaning or utility in a context outside of word processing. The way I would handle this in HTML by is creating a style called “No Break” to apply to such bits of text, and adding this to my CSS compile format pane:
.no-break { white-space: nowrap; }
Yes, it says white-space, but I believe most HTML readers will block all wrapping within the range, treating it as though it has non-breaking spaces between every character.
That would be inserted as a <span> ... </span> or what ?
If I just put it in the styles section of the stylesheet, doesn’t it make it only applicable to whole paragraphs ?
P.S. Sorry, I thought you meant the stylesheet in the Epub…
If you create a character style in your project called “No Break”, and apply it to some text, then:
The software will insert the <span class="no-break">...</span> for you, wrapped around the styled text. Easy peasy.
You don’t have to add anything to the Styles section of your compile settings. That’s only necessary if you want to change how the text looks, or how it functions to some degree (for example you can manually set the CSS class name, if the internal style name you use for the project would be awkward).
If I just put it in the styles section of the stylesheet, doesn’t it make it only applicable to whole paragraphs ?
That’s not how CSS works, unless the selector specifically declares paragraph elements in its scope, a “bare” class description can be applied to anything.
p.no-break : Only paragraphs will be formatted
h1.no-break : Only level 1 headings will be formatted
.no-break : Anything, even the <body> can be formatted.
So, basically, if I get this right, all you have to know is the proper span=x description/name, and create a character style of that name in Scrivener. Right ?
I’d say it more the other way around. If you experimented with the instructions and tried calling your character style “Flapping Wings of a Butterfly”, then you would find:
Blah blah <span class="flapping-wings-of-a-butterfly">loud cussing</span> and blah.
And then of course we’d want to paste this into the CSS compile format pane (not your compiled ePub! That will only work until you compile again) instead:
Yes, that’s fine, just that. The only reason you would want more is to override some of the automatically generated stuff in the first line. The cascading part of Cascading Style Sheets is in part this principle:
p { font-size: 12pt }
p { text-indent: 2em }
Results in a combination of the two attributes together. Thus, one stylesheet coming out of the software can set up appearance attributes, and your stylesheet can set up special instructions like white-space handling, and the ebook reader itself can have deep defaults that nobody has to bother with setting. One cascades into the next, resulting in a whole.
Open DuckDuckGo, type in “css thing I want to do”, and reap the rewards of several decades of people figuring out how to do neat things. Nothing wrong with that! I search for tricks all the time, and I know CSS at a fairly advanced level.
Drop caps, text flowing around images, text columns, numerical counters, custom list designs…
…since I used “Append custom CSS stylesheet” in the CSS pane of the compile format, does it matter that my .no-break and its {definition} end up at the very bottom of the epub’s stylesheet ?
[EDIT ]I mean, if it could be a problem.
But on second thought, if it happens to be, I could always just move it up with the others. So I guess it wouldn’t be a big deal…
That’s precisely what you want in fact. The cascade principle means the last one doing the talking gets the final say on the attributes it adds or changes. It doesn’t really matter in this case, because nothing other than core browser default behaviour is going to have anything to say about the white-space policies.
But specifically we do put your stuff last to give you that final vote. Say you want colour for this style in the editor so you can see what you’ve done at a glance, but you don’t actually want grey text on an eInk screen. You could fix that up in the Styles compile format pane—but you could also just type it in as CSS yourself, too: