mandoc
Initial release | November 2008 |
---|---|
Stable release |
1.13.4
/ July 14, 2016[1] |
Written in | C |
Operating system | Cross-platform |
Type | Typesetting |
License | ISC license |
Website |
mdocml |
mandoc (historically called mdocml) is an ISC licensed utility for formatting man pages, specifically those written in the mdoc macro language. 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.
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.[2] It was then showcased at AsiaBSDCon-2009.[3][4][5] In summer of 2010, mandoc was the subject of a NetBSD-mentored Google Summer of Code project[6] for producing PostScript and PDF output alongside the existing text, HTML, and XHTML outputs. This work was completed in August 2010.[7] mandoc became the default formatter of manuals for OpenBSD 4.8, released in November 2010.[8][9] It later became the default formatter in NetBSD, FreeBSD, illumos, Void Linux and Alpine Linux, and is also included in DragonFlyBSD and MINIX 3.[10] Its advantages were stated as high speed,[11] license, and clean reimplementation.
While mandoc works well with the mdoc manuals used in the BSD Operating Systems, it poorly handles older troff macros such as man, me, and the roff language itself. This makes it a poor fit for Linux distributions, which primarily use man troff macros and low-level roff for their manual pages.
mandoc has built-in support for the troff soelim preprocessor and partial built-in support for tbl and eqn. It has strong support for wide-character output. It can also use the semantic information in mdoc manuals along with sqlite to implement semantic search.
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.
# 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 with the included preconv recoding utility. In this example, foo.jp.1 is a Japanese manual encoded in UTF-8. It assumes that the user's terminal has support for locales.
# Pipe wide-character output to a pager.
$ preconv -e utf-8 foo.jp.1 | mandoc -Tlocale | less
# XHTML output with manual links.
$ preconv -e utf-8 foo.jp.1 | mandoc -Txhtml -Oman=%N.%S.xhtml >foo.1.xhtml
The included apropos implementation can use semantic information in search:
# Search for all functions starting with 'str' having return type size_t:
$ apropos -s 3 Ft=size_t -a Nm~^str
References
- ↑ "Changes in version 1.13.4, released on July 14, 2016". July 14, 2016.
- ↑ "Source history". Mdocml.bsd.lv. Retrieved 2010-12-18.
- ↑ "AsiaBSDCon 2009: Deprecating groff for BSD manual display". 2009.asiabsdcon.org. 2009-03-15. Retrieved 2010-12-18.
- ↑ "Deprecating groff for BSD manual display" (PDF). Retrieved 2010-12-18.
- ↑ “”. "Video of AsiaBSDCon presentation". Youtube.com. Retrieved 2010-12-18.
- ↑ "Google Summer of Code: mandoc_ps". Netbsd-soc.sourceforge.net. Retrieved 2010-12-18.
- ↑ "NetBSD Blog". Blog.netbsd.org. 2010-08-11. Retrieved 2010-12-18.
- ↑ "OpenBSD 4.8". Openbsd.org. 2010-11-01. Retrieved 2010-12-18.
- ↑ "groff deleted from tree".
- ↑ "Availability of the mandoc toolset". Mdocml.bsd.lv.
- ↑ mandoc speed benchmarks
External links
- Mandoc (mdocml) site
- Undeadly article on mandoc
- Google Summer of Code mandoc_ps project site
- Freecode page for mandoc