mandoc

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

mandoc
Initial releaseNovember 2008
Stable release
1.14.5 / March 10, 2019; 4 months ago (2019-03-10)[1]
Repository Edit this at Wikidata
Written inC
TypeTypesetting
LicenseISC license
Websitemandoc.bsd.lv

mandoc (historically called mdocml) is an ISC licensed utility for formatting man pages, specifically those written in the mdoc and man macro languages. Unlike the groff and older troff and nroff tools predominantly used for this purpose, mandoc focuses specifically on manuals and is not suitable for general-purpose type-setting.

mandoc 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.[2][1](1.14.5) It does not support other macro sets such as mm and ms, or any typesetting features like hyphenation, fonts, and alignment.[2](compatibility)

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.[1](1.4.1)

History[edit]

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.[3] It was then showcased at AsiaBSDCon-2009.[4][5][6] In summer of 2010, mandoc was the subject of a NetBSD-mentored Google Summer of Code project[7] for producing PostScript and PDF output alongside the existing text, HTML, and XHTML outputs. This work was completed in August 2010.[8] mandoc became the default formatter of manuals for OpenBSD 4.8, released in November 2010.[9][10] It later became the default formatter in NetBSD, FreeBSD, illumos, Void Linux and Alpine Linux, and is also included in DragonFlyBSD, MINIX 3, Debian, Ubuntu, Gentoo, and Fedora.[11] Its advantages were stated as high speed,[12] license, and clean reimplementation.

Sample usage[edit]

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.[13]

 # Pipe output to a pager.
 $ mandoc foo.1 | less
 # 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.[13]

 # Pipe wide-character output to a pager.
 $ mandoc foo.jp.1 | less

The included apropos implementation can use semantic information in search:[14]

 # Search for all functions starting with 'str' having return type size_t:
 $ apropos -s 3 Ft=size_t -a Nm~^str


Other features[edit]

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

References[edit]

  1. ^ a b c "Release notes". March 10, 2019.
  2. ^ a b roff(7) – OpenBSD Miscellaneous Information Manual
  3. ^ "Source history". Mdocml.bsd.lv. Retrieved 2010-12-18.
  4. ^ "AsiaBSDCon 2009: Deprecating groff for BSD manual display". 2009.asiabsdcon.org. 2009-03-15. Retrieved 2010-12-18.
  5. ^ "Deprecating groff for BSD manual display" (PDF). Retrieved 2010-12-18.
  6. ^ "Video of AsiaBSDCon presentation". Youtube.com. Retrieved 2010-12-18.
  7. ^ "Google Summer of Code: mandoc_ps". Netbsd-soc.sourceforge.net. Retrieved 2010-12-18.
  8. ^ "NetBSD Blog". Blog.netbsd.org. 2010-08-11. Retrieved 2010-12-18.
  9. ^ "OpenBSD 4.8". Openbsd.org. 2010-11-01. Retrieved 2010-12-18.
  10. ^ "groff deleted from tree".
  11. ^ "Availability of the mandoc toolset". Mdocml.bsd.lv.
  12. ^ Unangst, Ted. "mandoc speed benchmarks".
  13. ^ a b c mandoc(1) – OpenBSD General Commands Manual
  14. ^ apropos(1) – OpenBSD General Commands Manual
  15. ^ man.cgi(8) – OpenBSD System Manager's Manual

External links[edit]