Saturday, January 8, 2011

Text - Groff and Mom

v 0.3

I've always had a partiality towards producing documents using text markup.  It has been limited in the past towards having a play writing my on personalised "Man" pages for my Linux machine, or writing html using markup (which drives my Nephew nuts because he likes Dreamweaver).  It rubs off onto my Daughter as well, since she prefers markup for her html coding as well.  Perhaps the fact that she is a Script-writer has something to do with it.

I was interested to see that Groff is included in my Cygwin install (unsurprisingly) so I started to wonder if it was a useful tool for writing letters and other documents.  If you have a useful template, then just changing some of the content is far easier than opening a Word Processor and starting afresh - or even finding that letter that you wrote some time ago to change a few things.  Of course, that the hardware needs of such a system are far less than the requirements of a Word Processor come into play.

The first thing I stumbled on was this linxgazette article on Groff and Mom.  So then I went to the Mom Homepage and started reading further.  Despite Mom being included in Groff (and it is, in Cygwin as well) I downloaded the latest version of Mom to have a look.  Within the file there is the documentation and numerous examples, as well as the macro definition file " om.tmac ".  There is an " install " file to read, however in the end, if you put the " om.tmac " file in the home directory, all should be well (though I haven't tried that yet).

The moment of truth.  I opened a Cygwin command line window, which, since I've set the HOME environment variable, opened in my HOME directory.  I'm not going to go into the logic of the Unix command line here - please refer elsewhere - the Rute User Tutorial on the links page is an excellent place to start.  Using one of the sample " mom " files that came with the Mom download:

groff -mom letter.mom > letter.ps

And low and behold, a postscript file appeared.  The documentation had a slightly different syntax to send the file to the printer, so I tried that, even though my default printer is not postscript.

groff -mom -Tps letter.mom | lpr

The raw postscript printed fine on my default printer, so even though I didn't have the "beautiful" result at this stage, I did know that the command line worked and sent files to the printer.

Windows does not have the capabilities to read postscript files in a viewer that other operating systems do, so the next step is to get Ghostscript, the free Postscript interpreter and viewer.  The presentation of postscript files is a little problematical, depending on the font that is used, however the printed article seems to work fine.

There is a script included in Ghostscript that you can use to convert the file to a "pdf" file.

ps2pdf letter.ps > letter.pdf

NOW you can open the letter in a pdf viewer and print it from there.  You'll notice that the clarity of the text in pdf format is MUCH better than the postscript viewer.

All you have to do now is read the documentation, and have a play.  You are up and running with Mom!!

Update 17th Jan

Other Macro Packages

The other two macro packages I could find documentation for were the "ms" and "me" packages showing how to use them.  See the Links page.


Using Emacs to Edit Groff

Emacs has a built in " nroff " mode.  To activate it, either issue issue the command via:

M-x nroff-mode

or making the first line of your Groff source document:

\" -*- mode:nroff -*-

\"  is the comment in Groff, so the mode instruction line will remain invisible.  Using Nroff mode, all macros will be highlighted for easier editing.


Later ....

No comments:

Post a Comment