TechWhirl (TECHWR-L) is a resource for technical writing and technical communications professionals of all experience levels and in all industries to share their experiences and acquire information.
For two decades, technical communicators have turned to TechWhirl to ask and answer questions about the always-changing world of technical communications, such as tools, skills, career paths, methodologies, and emerging industries. The TechWhirl Archives and magazine, created for, by and about technical writers, offer a wealth of knowledge to everyone with an interest in any aspect of technical communications.
Re: Need guidance on scripting program code into FrameMaker
Subject:Re: Need guidance on scripting program code into FrameMaker From:"Sandy Harris" <sharris -at- dkl -dot- com> To:"Guy K. Haas" <ghaas -at- selectica -dot- com> Date:Fri, 03 Mar 2000 16:12:37 -0500
"Guy K. Haas" wrote:
>
> O TECHWR-L gurus--
>
> I'm working in a WinNT environment.
>
> I have a corpus of code chunks that I want to import into a
> FrameMaker doc -- a reference manual about an API.
>
> These chunks are sample/example code, and the developers are
> fiddling with them actively. I want to be able to snatch them
> up and publish them every few weeks without a lot of handwork.
>
> What kind of handwork?
>
> I want to
> -replace any initial tabs with a set of 4 spaces, then
> replace any set of 4 initial spaces with a tab,
> -omit lines that contain a certain text
I'd do those with the standard-since-the-70s Unix tool 'sed',
the stream editor. Both are one-line sed commands. Put the
commands in a file, and do:
sed -f sedscript < inputfile > outputfile
You can do much fancier things with sed, and even more with
the 'awk' text processing programming language. O'Reilly
publish a good book on those tools, by Dougherty.
There are a full set of free Unix tools for 95/98/NT at:
but I'd suggest you just ask if your developers can grab
sed source from the nearest Linux box and compile it for
you on NT.
I don't know Perl, but it is supposed to do eveything awk
and sed can.
> -have each file come in as a single FrameMaker paragraph,
> not a paragraph per incoming line.
> ... when I
> use Perl to replace the "newline" or even "\0D\0A" (CR/LF)
> with a \f (formfeed) or \r (return), and use the first option,
> I still get one paragraph per line when I import.
>
Try \n for newline. Unix term for linefeed. DOS/Windoze lines
end with CR LF, Unix with LF only and I think Mac is CR only.