1

I have a source document that I'm trying to clean up, it's essentially plain text. But the author has bold text indicated with { } brackets, and italics indicated with < > brackets.

I would like to be able to automatically convert these to the proper style. Is there a way to accomplish this? It's nearly 200 pages, and on some there are 30+ instances on a single page. This will be weeks of work at the rate I'm going.

I've got the latest Pages (and no older version to fall back on). Is there a way to do this?

  • Do you have to use Pages then? It might be easier to do it as an RTF or something else then copy and paste it into Pages. – JMY1000 Sep 20 '16 at 17:15
  • @JMY1000 I don't see any workflow that would allow this to be a reasonable work-around. What rtf editor would accomplish this so I could paste it back in? Additionally, in order to make italics work, I'm having to bump up the character spacing too, which seems to be a Pages-only thing. – John O Sep 20 '16 at 17:28
  • Working with a less proprietary format means it could be possible to write a script that does it for you. Are you bumping the character spacing up universally or just for certain areas? – JMY1000 Sep 20 '16 at 17:29
  • In addition, are there areas that are both bold and italic or no? And why are you doing this? There might be an easier way. – JMY1000 Sep 20 '16 at 17:31
  • @JMY1000 There don't seem to be any formats other than bold or italic, never both. Other formatting needs to be done manually, but it amounts to running through it and changing section heading styles and indenting some (but not all) paragraphs. That stuff I could run through in an hour or two. As for why, I'm getting tired of looking at ugly assed plain text in courier. Decided to attempt to retypeset this. – John O Sep 20 '16 at 17:33
1

I would recommend simply editing the file in .rtf, as it contains support for bold and italic but isn't anywhere near as complex as Pages files.

RTF uses a tag based system denotes certain properties with the backslash "\" as the control word, which is somewhat human readable.. Take a look at these two pieces: one the formatted .rtf and the other the plaintext (or code.)

This is a test.

{\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf470
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\margl1440\margr1440\vieww10600\viewh10400\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0

\f0\fs24 \cf0 This 
\b is
\b0  
\i a
\i0  test.}

Stripping out the metadata, we still have a valid .rtf file, just with less formatting (which we don't need anyways.)

{This 
\b is
\b0
\i a
\i0  test.}

We don't even need those newlines.

{This \b is \b0 \i a \i0 test.}

With this, it becomes pretty trivial to convert your text: all we need is find and replace. First, create a .txt with all the data and open it in your favorite text editor–even TextEdit will do. Simply find and replace:

  • { with \b
  • } with \b0
  • < with \i
  • > with \i0

Note the whitespace (you may have to open the markdown code to see it.)

All we need to do now is add a curly brace at the start and the end, and we're done!

Lorem ipsum dolor sit amet, {consectetur adipiscing elit.} Donec placerat turpis in ligula ullamcorper, eget finibus ligula pretium. Etiam pellentesque {rutrum varius. Proin non} nunc quam. Pellentesque vestibulum quam enim, ac mollis metus venenatis eget. Vestibulum purus nulla, gravida quis erat ac, <luctus venenatis nunc. Pellentesque ac posuere dolor, sed tincidunt arcu.> Duis sodales magna justo, non porta turpis <aliquam eu. Etiam tempor, enim eget maximus tincidu{nt, orci justo} consequat erat, ac elementum justo enim ullamcorper ex. Nunc libero ex, efficitur eget neque commodo, tempus hendrerit ipsum. Ut id placerat> mauris, eu porta nulla. Donec ultrices lectus non elit condimentum sollicitudin. Mauris molestie felis eget hendrerit lobortis. Cras scelerisque et tellus nec ultricies. Nam nisi urna, vehicula eget posuere sed, interdum eu {sem.}

Lorem ipsum dolor sit amet, \b consectetur adipiscing elit. \b0 Donec placerat turpis in ligula ullamcorper, eget finibus ligula pretium. Etiam pellentesque \b rutrum varius. Proin non \b0 nunc quam. Pellentesque vestibulum quam enim, ac mollis metus venenatis eget. Vestibulum purus nulla, gravida quis erat ac, \i luctus venenatis nunc. Pellentesque ac posuere dolor, sed tincidunt arcu. \i0 Duis sodales magna justo, non porta turpis \i aliquam eu. Etiam tempor, enim eget maximus tincidu\b nt, orci justo \b0 consequat erat, ac elementum justo enim ullamcorper ex. Nunc libero ex, efficitur eget neque commodo, tempus hendrerit ipsum. Ut id placerat \i0 mauris, eu porta nulla. Donec ultrices lectus non elit condimentum sollicitudin. Mauris molestie felis eget hendrerit lobortis. Cras scelerisque et tellus nec ultricies. Nam nisi urna, vehicula eget posuere sed, interdum eu \b sem. \b0

Things to note: RTF doesn't support non-ASCII characters by default. If you need/want to use them, you'll need to do enter them specially using the \u control.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .