gmi2groff is a command-line tool for converting Gemtext files into Groff documents, utilizing the MOM macro package.
For practical illustration, refer to the example files:
- Automatic TOC: Use the
--tocflag for an automatically generated TOC positioned within the document. - Image Integration: Seamlessly processes
.epslinks to include images. - Customizable Settings: Define document appearance using a configuration file for personalized output.
Make sure the following are installed on your system:
- Python 3: Required to run the script.
- Groff: Necessary for processing
.momfiles. - Ghostscript: Converts PostScript outputs to PDF.
- A PDF viewer: Such as Zathura, for viewing the resulting PDF document.
Clone the repository** to your local machine:
git clone <repository-url>Execute the gmi2groff script using:
./gmi2groff <input_file> <output_file> [--settings <settings_file>] [--toc]<input_file>: The Gemini format text input file.<output_file>: The desired Groff output filename, typically.mom.--settings <settings_file>: (Optional) A file containing custom document settings.--toc: (Optional) A flag to include a table of contents in the output document.
Links pointing to .eps images within the Gemini text are automatically processed.
=> /path/to/image.eps Image Description
The script converts these links to Groff's .PDFPIC commands, inserting the image into the document with the associated description.
To convert input.gmi to a PDF with custom settings and a table of contents:
-
Convert the Gemtext file to Groff:
gmi2groff input.gmi output.mom --settings custom_settings.txt --toc
-
Convert Groff to PDF and view in zathura (PDF Viewer):
groff -mom output.mom -Tps -P-pa4 -Kutf8 > output.ps && ps2pdf output.ps output.pdf && rm output.ps && zathura output.pdf
Personally, I don't use
pdfmomhere because sometimes it produces a slightly different output.
Create a custom settings file to adjust typography and layout:
.PRINTSTYLE TYPESET
.PAPER A4
.FAMILY T
.LS 20
.PT_SIZE 12
Read the MOM Macro Handbook for more options.
The MIT License (MIT) Copyright © 2024 by mono@yol.li