grohtml Command in Linux



grohtml stands for "GNU troff HTML", which is an HTML driver for groff. The grohtml command in Linux helps us convert the output of GNU troff into HTML format.

You can use grohtml by running it through the groff command. Make sure to add the "-Thtml" option, which tells Groff to convert the document into HTML format. If you don't specify any files, grohtml will read from stdin (standard input). The HTML output will be displayed in the standard output. When you run grohtml via groff, you can pass options to grohtml using Groff's -P option.

Table of Contents

Here is a comprehensive guide to the options available with the grohtml command in linux −

What is grohtml Command?

The grohtml is a Linux command that belongs to the Groff (GNU troff) document processing system. It converts the input files that are written in Groff's markup language and generates an HTML output. This command lets us convert documents made with Groff into HTML format, which is better suited for use on the web.

grohtml Command Installation in Linux

Grohtml is not pre-installed on most Linux systems. However, since it belongs to the Groff package, we can install it using the package manager for our distribution.

For example, on Debian/Ubuntu, we can use the command −

sudo apt install groff

Similarly, we can use DNF to install grohtml on Fedora −

sudo dnf install groff

If you are an Arch Linux user, you can install grohtml using the following command −

sudo pacman -S groff

After installing groff, you can confirm the grohtmls installation on your system by running the following command −

grohtml -v

It will show you the installed version of groff.

Syntax of grohtml Command

You can use the following syntax to run the grohtml command in Linux −

grohtml [ -vhlrn ] [ -Ddir ] [ -Fdir ] [ -iresolution ] [ -Iimage-stem ] [ -oimage-vertical-offset ] [ -aaa-text-bits ] [ -aaa-graphic-bits ] [ files... ]

grohtml Command Options

The table below shows the available options of the grohtml command, along with their descriptions and default values −

Option Description
-aaa-text-bits It specifies the number of bits of antialiasing for text in PNG images. The default value is 4; valid values are 0, 1, 2, and 4.
-gaa-graphic-bits It specifies the number of bits of antialiasing for graphics in PNG images. The default value is 4; valid values are 0, 1, 2, and 4.
-b It sets the background color to white.
-h It generates section and number headings using ... with larger font sizes instead of ... tags.
-I It disables the automatic creation of section links at the top of the document.
-r It disables the automatic header and footer line (HTML rule).
-n It creates simple heading anchors for section or number headings. If a heading contains a question mark "?", it can cause issues in some browsers.
-p It shows page rendering progress to standard error. It is important to note that it shows the page number only when an image is required.
-F dir It adds directory dir or devname to the search path for font and device description files. The device name is usually HTML.
-iresolution It selects the resolution for all images, defaulting to 100 pixels per inch. E.g., -i200 indicates 200 pixels per inch.
-Istem It specifies the image stem name. If skipped, it uses grohtml-XXX (where XXX is the process ID).
-overtical-offset It sets the vertical offset of images in points.
-D dir This option instructs grohtml to place all image files into the specified directory dir.
-v It returns the version number of grohtml on the terminal.

grohtml Command Man Page

The man page of grohtml provides all the essential details about the command, including its name, synopsis, description, options, files, examples, related commands, and author information.

You can access it by executing the following command −

man grohtml
grohtml Command Man Page

Examples of grohtml Command in Linux

Lets go through the following examples to learn how the grohtml command works in Linux −

  • Converting a Groff file to HTML using grohtml
  • Specifying an Output Directory for the Output File
  • Processing Multiple Files With grohtml Command
  • Creating an HTML File with Navigation Links

Converting a Groff file to HTML using grohtml

The following command takes the content from exampleFile.groff and creates a new HTML file named exampleFile.html −

grohtml exampleFile.groff -o exampleFile.html

The converted file lets us view the document in a web browser.

Specifying an Output Directory for the Output File

The below-given command process the input file exampleFile.groff and redirects the output to the specified directory −

grohtml exampleFile.groff -o /path/to/outputDir/exampleFile.html

The above command specifies a directory for the output HTML file.

Processing Multiple Files with grohtml Command

You can specify multiple groff files in the grohtml command using a space-separated syntax. As a result, the grohtml command converts the specified Groff files into a single HTML file −

grohtml example1.groff example2.groff example3.groff -o outputFile.html

This command will convert the groff files example1, example2, and example3 to a single HTML file named outputFile.html.

Creating an HTML File with Navigation Links

You can run the grohtml command with the -n option to create an HTML file with the navigation links −

grohtml -n exampleFile.groff -o exampleFile.html

This command will convert the exampleFile.groff document into an HTML file named exampleFile.html. Moreover, it will generate simple heading anchors for each section in the output.

Conclusion

The grohtml command is a powerful tool for converting Groff documents into web-friendly HTML format. By using the appropriate options, users can customize the output to meet specific needs, such as specifying output directories, processing multiple files, and adding navigation links.

While grohtml is not pre-installed on most Linux systems, it can be easily installed through package managers. In this post, we covered the basic syntax, installation steps, available options, and practical examples to help users effectively utilize the grohtml command for their document conversion tasks.

Advertisements