Non-breaking space after any one digit character

Discuss scripting using AppleScript in QuarkXPress 2015, 2016, 2017 & 2018.
Discuss scripting using JavaScript in QuarkXPress 2018.
Post Reply
Posts: 2
Joined: 31 Dec 1969, 19:00

Non-breaking space after any one digit character

Post by yorick77 » 16 Jul 2018, 10:25

How to place non-breaking space after one digit characters? For example, after 'I', 'a'. Do you have any idea?

User avatar
Posts: 459
Joined: 05 Jun 2013, 12:55

Re: Non-breaking space after any one digit character

Post by MikeWenzloff » 16 Jul 2018, 13:16

If you have QXP 2018, this can be done using a two-step process using the as-shipped GREP Search and Replace JavaScript followed by Quark's regular Find/Change. Kind of a hack, but I think it will work for you.

As I use a PC, I have no idea about using AppleScript.

Do this on a copy of your publicatino, OK? And then check it over carefully.

So for QXP 2018, open the JavaScript panel from the Window menu.
Open the Samples section by double-clicking on it.
Double-click on the GREP Search and Replace JS.
An input dialog will display. In the entry field, enter the following:


You will need to enter the remaining characters between the two brackets. That includes any accented characters if used.

  • All JavaScript must begin with the forward slash.
  • The \s represents a space. So we are looking for a space followed by any single lowercase character that is between the square brackets followed by another space.
  • The characters between the two square brackets are the only letters the GREP will find when preceded and followed by a space.
  • The parentheses that both the \s and the lowercase characters I am using are so the GREP will remember them for replacing later.
  • The /g is so the search is global and won't stop after a match.
OK. Once satisfied by the GREP find string, press OK. Another input dialog will appear. In it, type the following:


The dollar symbols represent, here in the order of, the two items that are within the two sets of parenthesis in the find string. So $1 will replace the leading space with a space. The $2 will replace the single character. The ZZ is to replace the space you want the non-breaking space with two cap Z characters for the next step, the Find and Replace.

Assuming all went well, open the Find/Change dialog from the edit menu.
Make sure your text cursor is at the beginning of the text box.
Expand the dialog by unchecking Quark's default of Ignore Attributes.
In the Find entry box, enter ZZ
In the Change To entry, double-click in it so any space characters entered in it are highlighted and then simply type a single space character.
Below the Change To entry field, there is a checkbox for Special. Check that box and change the dropdown to Non Breaking.
Click on the Find First button, and then either the Change button, the Change, then find button, or the Change All button.

Hopefully the above makes sense. Aside from doing this on a copy of your document, you could also do this on a new, trial publication with a copy of some of the real text until you are assured it works for you.

I would also save any publication under a new name, and for your working publication this is especially true. I would then look throughout it to make sure it worked--and that my instructions don't mess up your file!

Take care, Mike

Post Reply

Return to “QuarkXPress 20xx: Scripting (AppleScript / JavaScript)”