Skip to content

hinman/ox-mom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ox-mom — Groff MOM Export Backend for Org Mode

An Org Mode export backend that produces Groff MOM macro documents from .org files. MOM is a high-level macro set bundled with GNU Groff that targets print-quality typesetting. Exported files are processed with pdfmom to produce PDF output.

Requirements

  • GNU Emacs 27.1 or later
  • Org Mode 9.6 or later
  • GNU Groff 1.22.4 or later (provides pdfmom)

Optionally:

On macOS, both can be installed via Homebrew:

brew install groff source-highlight

On Debian/Ubuntu:

apt install groff source-highlight

Installation

Manual

Clone the repository and add it to your load path:

(add-to-list 'load-path "/path/to/ox-mom")
(require 'ox-mom)

use-package with straight.el

(use-package ox-mom
  :straight (:host github :repo "hinman/ox-mom"))

Usage

Exporting

With point in an Org buffer, invoke the Org export dispatcher (C-c C-e) and press m to reach the MOM submenu:

KeyAction
m bExport to a MOM buffer
m fExport to a .mom file
m pExport to PDF via pdfmom
m oExport to PDF and open the file

You can also call the export functions directly:

(org-mom-export-to-pdf)

Document keywords

Place these in your .org file’s preamble to control export behaviour.

KeywordDescriptionDefault
#+TITLEDocument title
#+AUTHORAuthor name
#+DATEDocument date
#+MOM_DOCTYPEDocument type (see below)DEFAULT
#+MOM_PREAMBLERaw MOM macros inserted before .START

Document types

Set #+MOM_DOCTYPE to one of the following values.

DEFAULT / CHAPTER

Standard typeset document. Paper size, font family, and point size are controlled by the customisation variables org-mom-paper, org-mom-font-family, and org-mom-pt-size.

LETTER

Produces a formatted business letter. Additional keywords:

KeywordDescription
#+MOM_LETTER_TORecipient name and address (multiline)
#+MOM_LETTER_FROMSender name and address (multiline)
#+MOM_LETTER_CCCarbon-copy recipient
#+MOM_LETTER_SUBJECTSubject line
#+MOM_LETTER_GREETINGOpening salutation
#+MOM_LETTER_CLOSINGClosing phrase

Example:

#+MOM_DOCTYPE: LETTER
#+MOM_LETTER_TO: Jane Smith
#+MOM_LETTER_TO: 456 Oak Avenue
#+MOM_LETTER_FROM: Lee Hinman
#+MOM_LETTER_GREETING: Dear Ms. Smith,
#+MOM_LETTER_CLOSING: Sincerely,

SLIDES

Produces a PDF slide deck. Each top-level headline becomes a new slide. Additional keywords:

KeywordDescriptionDefault
#+MOM_SLIDES_ASPECTAspect ratio passed to .DOCTYPE SLIDES16:9
#+MOM_SLIDES_HEADERSlide header string
#+MOM_SLIDES_FOOTERSlide footer string
#+MOM_SLIDES_TRANSITIONPDF page transition effect
#+MOM_SLIDES_PAUSEPDF pause effect between slides

Source blocks

Source blocks are syntax-highlighted in the exported PDF when org-mom-source-highlight is non-nil (the default) and GNU source-highlight is available. The languages supported are listed in org-mom-source-highlight-langs.

eqn and pic blocks

Source blocks whose language is eqn or pic are passed directly to the corresponding Groff preprocessors rather than rendered as code listings. pdfmom is invoked with -e (eqn) and -p (pic) flags to enable them.

#+begin_src eqn
x = {-b +- sqrt{b sup 2 - 4ac}} over {2a}
#+end_src

#+begin_src pic
box "Emacs"; arrow; box "Org Mode"
#+end_src

Raw MOM output

Use an export block or the MOM keyword to pass raw Groff/MOM markup through to the output unchanged:

#+begin_export mom
.CENTER
This line is centred by a raw MOM macro.
#+end_export
#+MOM: .SP 2

Inline MOM snippets work too with the @@mom:…@@ syntax:

This word is @@mom:\f[B]@@bold@@mom:\f[P]@@ by raw escape.

Images

Inline images are exported using MOM’s .PDF_IMAGE macro. The :width and :height attributes are forwarded:

#+ATTR_MOM: :width 3i :height 2i
[[file:diagram.pdf]]

Supported formats: jpg, png, pdf, ps, eps, pic.

Tables

Tables are rendered using the Groff tbl preprocessor. The :divider attribute adds vertical rules; :center centres the table; :title-line makes the first row bold:

#+ATTR_MOM: :divider t :title-line t
| Language | Year | Paradigm   |
|----------+------+------------|
| Lisp     | 1958 | Functional |
| C        | 1972 | Imperative |

Customisation

VariableDescriptionDefault
org-mom-paperPaper size (.PAPER macro)"LETTER"
org-mom-font-familyFont family (.FAMILY macro)"T" (Times)
org-mom-pt-sizePoint size (.PT_SIZE macro)12
org-mom-doctypeDefault document type (.DOCTYPE macro)"DEFAULT"
org-mom-pdf-processShell commands used to compile .mom to PDFThree runs of pdfmom -p -t -e -K utf-8
org-mom-source-highlightEnable GNU source-highlight for source blockst
org-mom-source-highlight-langsMapping of Org language names to source-highlight namessee variable docstring
org-mom-eqn-pic-exportsDefault :exports value for eqn and pic blocks"code"
org-mom-tables-centeredCentre tables by defaultt
org-mom-inline-image-rulesFile extensions recognised as inline imagessee variable docstring
org-mom-format-headline-functionCustom function for formatting headline textnil
org-mom-format-drawer-functionCustom function for formatting drawersnil

All variables belong to the ox-mom customisation group (M-x customize-group RET ox-mom RET).

About

Org Mode exporter for groff MOM macro

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors