Mandoc

Manpage formatter


title: "Mandoc" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["bsd-software", "openbsd-software-using-the-isc-license"] description: "Manpage formatter" topic_path: "general/bsd-software" source: "https://en.wikipedia.org/wiki/Mandoc" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0

::summary Manpage formatter ::

::data[format=table title="Infobox software"]

FieldValue
namemandoc
releasedNovember 2008
latest release version1.14.6
latest release date
programming languageC
genreTypesetting
licenseISC license
::

| name = mandoc | screenshot = | caption = | author = | developer = | released = November 2008 | latest release version = 1.14.6 | latest release date = | programming language = C | genre = Typesetting | license = ISC license mandoc (historically called mdocml) is a utility used for formatting man pages in BSD Operating Systems (e.g. NetBSD), specifically those written in the mdoc and man macro languages. Unlike the groff and older troff and nroff tools that are predominantly used for this purpose by tools such as , mandoc focuses specifically on manuals and is not suitable for general-purpose type-setting.

is mainly used to format the mdoc manuals used in the BSD Operating Systems, but it also implements most of the man macros used in Linux distributions, as well as a subset of roff commands occasionally intermixed with the man macros.

mandoc has built-in support for the troff soelim (inclusion) preprocessor and partial built-in support for tbl and eqn. It has strong support for UTF-8 output. It can also use the semantic information in mdoc manuals to implement semantic search, which before version 1.4.1, relied on sqlite.

History

Development began in November 2008 specifically to produce CSS-enabled HTML forms of manuals in response to the limitations of groff. mandoc gained initial text-mode output in February 2009. It was then showcased at AsiaBSDCon-2009. In summer of 2010, mandoc was the subject of a NetBSD-mentored Google Summer of Code project for producing PostScript and PDF output alongside the existing text, HTML, and XHTML outputs. This work was completed in August 2010. mandoc became the default formatter of manuals for OpenBSD 4.8, released in November 2010. It later became the default formatter in NetBSD, FreeBSD, illumos, Void Linux, Alpine Linux and macOS, and is also included in DragonFlyBSD, MINIX 3, Debian, Ubuntu, Gentoo, and Fedora. Its advantages were stated as high speed, license, and clean reimplementation.

Sample usage

The following demonstrates running mandoc on its own. Usually, it would be called via the man utility. In this example, foo.1 is the name of an mdoc UNIX manual. ::code[lang=console] $ # Page manual to the terminal. $ mandoc -l foo.1 $ # HTML output with a style-sheet. $ mandoc -Thtml -Ostyle=style.css >foo.1.html ::

Multibyte (localised) manuals may also be rendered without preprocessing. In this example, foo.jp.1 is a Japanese manual encoded in UTF-8. mandoc will automatically detect the encoding. ::code[lang=console] $ # Page wide-character manual to the terminal. $ mandoc -l foo.jp.1 ::

The included apropos implementation can use semantic information in search: ::code[lang=console] $ # Search for all functions starting with 'str' having return type size_t: $ apropos -s 3 Ft=size_t -a Nm~^str ::

Other features

  • mandoc supports HTML 5, PostScript, and PDF output via the parameter.
  • man.cgi is a CGI program designed to display manual pages on the web. OpenBSD uses it to format all its manual pages.

References

References

  1. (September 23, 2021). "Release notes".
  2. {{man. 7. roff. OpenBSD
  3. "Italics and colour in manual pages on a nosh user-space virtual terminal".
  4. {{man. 1. mandoc. FreeBSD. "Font styles are applied by using back-spaced encoding..."
  5. "Source history". Mdocml.bsd.lv.
  6. (2009-03-15). "AsiaBSDCon 2009: Deprecating groff for BSD manual display". 2009.asiabsdcon.org.
  7. "Deprecating groff for BSD manual display".
  8. "Video of AsiaBSDCon presentation". Youtube.com.
  9. "Google Summer of Code: mandoc_ps". Netbsd-soc.sourceforge.net.
  10. (2010-08-11). "NetBSD Blog". Blog.netbsd.org.
  11. (2010-11-01). "OpenBSD 4.8". Openbsd.org.
  12. "groff deleted from tree".
  13. "Availability of the mandoc toolset". Mdocml.bsd.lv.
  14. Unangst, Ted. "mandoc speed benchmarks".
  15. {{man. 1. mandoc. OpenBSD
  16. {{man. 1. apropos. OpenBSD
  17. {{man. 8. man.cgi. OpenBSD

::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::

bsd-softwareopenbsd-software-using-the-isc-license