[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Solved again] Program for quoting text like in email?



>>> OK, so I guess it should be sed 's/^/> /'.
>
>>However I noticed another problem. When I quote a text that is already
>>quoted, the result gets the "> " characters moved around. I would like
>>to get ">> " or "> > " for text that is quoted twice.
>
> What do you mean by "moved around"? Can you post an example?

Sure:

Example of the "> " characters being moved around after quoting three times:

> > > Lorem Ipsum is simply dummy text of the printing and typesetting industry.
> > > Lorem Ipsum has been the industry's standard dummy text ever since the
> 1500s, > > when an unknown printer took a galley of type and scrambled it
> to make a > > type specimen book. It has survived not only five centuries,
> but also the > > leap into electronic typesetting, remaining essentially
> unchanged. It was > > popularised in the 1960s with the release of Letraset
> sheets containing > > Lorem Ipsum passages, and more recently with desktop
> publishing software > > like Aldus PageMaker including versions of Lorem Ipsum.
> > > Lorem Ipsum is simply dummy text of the printing and typesetting industry.
> > Lorem Ipsum has been the industry's standard dummy text ever since the
> 1500s, > when an unknown printer took a galley of type and scrambled it
> to make a > type specimen book. It has survived not only five centuries,
> but also the > leap into electronic typesetting, remaining essentially
> unchanged. It was > popularised in the 1960s with the release of Letraset
> sheets containing > Lorem Ipsum passages, and more recently with desktop
> publishing software > like Aldus PageMaker including versions of Lorem Ipsum.
> > Lorem Ipsum is simply dummy text of the printing and typesetting industry.
> Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
> when an unknown printer took a galley of type and scrambled it to make a
> type specimen book. It has survived not only five centuries, but also the
> leap into electronic typesetting, remaining essentially unchanged. It was
> popularised in the 1960s with the release of Letraset sheets containing
> Lorem Ipsum passages, and more recently with desktop publishing software
> like Aldus PageMaker including versions of Lorem Ipsum.

> The sed script quoted above is very simple. It just puts "> " at the
> start of each line and should not move anything around.
>
> If you are piping the result to fmt(1), then I guess you'd see the
> "moving around" you might be talking about. If this is the problem, you
> may want to use par(1) instead (from the "par" package). par knows about
> quoting and preserves it properly when reformatting. It's got quite a
> few options, but I typically use it as "par 72q" - that uses 72 chars as
> the max line width and handles quoting.
>
> $ sed 's/^/> /' | par 72q

I used your example with "par" and it worked just as intended. Thanks again!

> A slightly more complicated sed script to use not put an extra space
> after the quote on already quoted text would be:
>
> $ sed -e 's/^>/>>/' -e '/^\([^>]\|$\)/s/^/> /' | par 72q

Thanks for this one too. It worked as well as you can see in this example:

>>>> Lorem Ipsum is simply dummy text of the printing and typesetting
>>>> industry. Lorem Ipsum has been the industry's standard dummy
>>>> text ever since the 1500s, when an unknown printer took a galley
>>>> of type and scrambled it to make a type specimen book. It has
>>>> survived not only five centuries, but also the leap into electronic
>>>> typesetting, remaining essentially unchanged. It was popularised
>>>> in the 1960s with the release of Letraset sheets containing Lorem
>>>> Ipsum passages, and more recently with desktop publishing software
>>>> like Aldus PageMaker including versions of Lorem Ipsum.
>>>
>>> Lorem Ipsum is simply dummy text of the printing and typesetting
>>> industry. Lorem Ipsum has been the industry's standard dummy text
>>> ever since the 1500s, when an unknown printer took a galley of type
>>> and scrambled it to make a type specimen book. It has survived not
>>> only five centuries, but also the leap into electronic typesetting,
>>> remaining essentially unchanged. It was popularised in the 1960s
>>> with the release of Letraset sheets containing Lorem Ipsum passages,
>>> and more recently with desktop publishing software
>>
>> Lorem Ipsum is simply dummy text of the printing and typesetting
>> industry. Lorem Ipsum has been the industry's standard dummy text
>> ever since the 1500s, when an unknown printer took a galley of type
>> and scrambled it to make a type specimen book. It has survived not
>> only five centuries, but also the leap into electronic typesetting,
>> remaining essentially unchanged. It was popularised in the 1960s with
>> the release of Letraset sheets containing Lorem Ipsum passages, and
>> more recently with desktop publishing software
>
> Lorem Ipsum is simply dummy text of the printing and typesetting
> industry. Lorem Ipsum has been the industry's standard dummy text
> ever since the 1500s, when an unknown printer took a galley of type
> and scrambled it to make a type specimen book. It has survived not
> only five centuries, but also the leap into electronic typesetting,
> remaining essentially unchanged. It was popularised in the 1960s with
> the release of Letraset sheets containing Lorem Ipsum passages, and
> more recently with desktop publishing software

-- 
Regards,

Thomas Anderson
"Quidquid latine dictum sit, altum sonatur"


Reply to: