Tuesday, April 14, 2009

How do I find paragraph marks and tabs in Pages?

If you want to search for paragraph marks, tabs or other special characters in Pages, you can do that in the search dialogue (Edit > Find > Find...) using the Insert... drop down.


If you prefer to use Applescript to find this kind of items, you can use the special keywords space, tab, return, linefeed and quote, for example like this:

tell application "Pages"
repeat with achar in characters of body text of front document
if contents of achar = return then
display dialog (character offset of achar as integer)
end if
end repeat
end tell

3 comments:

Eric said...

What's the difference between a paragraph break and a carriage return. Pages 08 didn't have this distinction. Pages 09 does. What does this benefit people?

Magnus Lewan said...

Eric, You are talking about the special characters in the advanced options of the Find dialogue, right?

What we usually want is to search for "Paragraph Breaks". They are generated for example by hitting the return key. The are stored as "br" in the index.xml file.

We may also want to search for "Line Breaks", which often look like Paragraph Breaks. They can be used for example to add some non-numbered lines in a list. To get a Line Break, one can press shift-return. They are stored as "lnbr" in the index.xml file.

When it comes to "Carriage Return", it matches a kind of line break, which I have not been able to generate in any sensible way. It anyhow is stored as "crbr" in the index.xml file. I guess it has something to do with compatibility, either with old Mac text files or with MS Word or some other file format, which generates that kind of line breaks.

Gary said...

Hi,

this is an interesting topic: is there a difference between paragraph endings and carriage returns? How does Pages handle this? I can give some general information:

Typewriters used two actions to proceed to the beginning of the next line. A carriage return (that brought the carriage to its first position) and a line feed (that advanced the drum). That has carried on into the computer age as two different actions and characters respectively:

Carriage Return, or Ascii 13, aka < br/>, aka '\r, etc.
and
Line Feed, or newline, Ascii 10, aka \n, etc.

On ancient computer systems (like Windows for example :-) both are used at the end of a paragraph.
On older Mac Systems (System ≤9) the return character (ascii 13) is used.
Since OS X, which builds on Unix, we have the newline character (ascii 10) for paragraph endings.

To minimize confusion, cross-platform applications, like for example php established a constant (PHP_EOL) that always uses the correct character (or combonation), no matter what you are using.

So: How does Pages handle, and most importantly names these characters?

Gary