=================================================================== RCS file: /cvs/mandoc/mandoc.1,v retrieving revision 1.169 retrieving revision 1.180 diff -u -p -r1.169 -r1.180 --- mandoc/mandoc.1 2017/01/10 12:53:07 1.169 +++ mandoc/mandoc.1 2017/03/20 14:32:24 1.180 @@ -1,4 +1,4 @@ -.\" $Id: mandoc.1,v 1.169 2017/01/10 12:53:07 schwarze Exp $ +.\" $Id: mandoc.1,v 1.180 2017/03/20 14:32:24 schwarze Exp $ .\" .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons .\" Copyright (c) 2012, 2014-2017 Ingo Schwarze @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 10 2017 $ +.Dd $Mdocdate: March 20 2017 $ .Dt MANDOC 1 .Os .Sh NAME @@ -26,7 +26,7 @@ .Op Fl acfhkl .Op Fl I Cm os Ns = Ns Ar name .Op Fl K Ar encoding -.Op Fl m Ns Ar format +.Op Fl mdoc | man .Op Fl O Ar option .Op Fl T Ar output .Op Fl W Ar level @@ -44,9 +44,7 @@ reads .Xr mdoc 7 or .Xr man 7 -text from stdin, implying -.Fl m Ns Cm andoc , -and produces +text from stdin and produces .Fl T Cm locale output. .Pp @@ -84,10 +82,10 @@ Override the default operating system .Ar name for the .Xr mdoc 7 -.Sq \&Os +.Ic \&Os and for the .Xr man 7 -.Sq \&TH +.Ic \&TH macro. .It Fl K Ar encoding Specify the input encoding. @@ -98,21 +96,29 @@ arguments are .Cm iso-8859-1 , and .Cm utf-8 . -If not specified, autodetection uses the first match: -.Bl -tag -width iso-8859-1 -.It Cm utf-8 -if the first three bytes of the input file -are the UTF-8 byte order mark (BOM, 0xefbbbf) -.It Ar encoding -if the first or second line of the input file matches the +If not specified, autodetection uses the first match in the following +list: +.Bl -enum +.It +If the first three bytes of the input file are the UTF-8 byte order +mark (BOM, 0xefbbbf), input is interpreted as +.Cm utf-8 . +.It +If the first or second line of the input file matches the .Sy emacs mode line format .Pp .D1 .\e" -*- Oo ...; Oc coding: Ar encoding ; No -*- -.It Cm utf-8 -if the first non-ASCII byte in the file introduces a valid UTF-8 sequence -.It Cm iso-8859-1 -otherwise +.Pp +then input is interpreted according to +.Ar encoding . +.It +If the first non-ASCII byte in the file introduces a valid UTF-8 +sequence, input is interpreted as +.Cm utf-8 . +.It +Otherwise, input is interpreted as +.Cm iso-8859-1 . .El .It Fl k A synonym for @@ -130,13 +136,28 @@ Also reverts any earlier and .Fl k options. -.It Fl m Ns Ar format -Input format. -See -.Sx Input Formats -for available formats. -Defaults to -.Fl m Ns Cm andoc . +.It Fl mdoc | man +With +.Fl mdoc , +all input files are interpreted as +.Xr mdoc 7 . +With +.Fl man , +all input files are interpreted as +.Xr man 7 . +By default, the input language is automatically detected for each file: +if the the first macro is +.Ic \&Dd +or +.Ic \&Dt , +the +.Xr mdoc 7 +parser is used; otherwise, the +.Xr man 7 +parser is used. +With other arguments, +.Fl m +is silently ignored. .It Fl O Ar option Comma-separated output options. .It Fl T Ar output @@ -201,56 +222,13 @@ also supports the options described in the .Xr apropos 1 manual. -.Ss Input Formats -The -.Nm -utility accepts -.Xr mdoc 7 -and -.Xr man 7 -input with -.Fl m Ns Cm doc -and -.Fl m Ns Cm an , -respectively. -The -.Xr mdoc 7 -format is -.Em strongly -recommended; -.Xr man 7 -should only be used for legacy manuals. -.Pp -A third option, -.Fl m Ns Cm andoc , -which is also the default, determines encoding on-the-fly: if the first -non-comment macro is -.Sq \&Dd -or -.Sq \&Dt , -the -.Xr mdoc 7 -parser is used; otherwise, the -.Xr man 7 -parser is used. -.Pp -If multiple -files are specified with -.Fl m Ns Cm andoc , -each has its file-type determined this way. -If multiple files are -specified and -.Fl m Ns Cm doc -or -.Fl m Ns Cm an -is specified, then this format is used exclusively. .Ss Output Formats The .Nm utility accepts the following .Fl T arguments, which correspond to output modes: -.Bl -tag -width "-T locale" +.Bl -tag -width "-T markdown" .It Fl T Cm ascii Produce 7-bit ASCII output. See @@ -274,6 +252,12 @@ Produce format output. See .Sx Man Output . +.It Fl T Cm markdown +Produce output in +.Sy markdown +format. +See +.Sx Markdown Output . .It Fl T Cm pdf Produce PDF output. See @@ -377,7 +361,7 @@ The string for example, .Ar ../src/%I.html , is used as a template for linked header files (usually via the -.Sq \&In +.Ic \&In macro). Instances of .Sq \&%I @@ -390,7 +374,7 @@ The string for example, .Ar ../html%S/%N.%S.html , is used as a template for linked manuals (usually via the -.Sq \&Xr +.Ic \&Xr macro). Instances of .Sq \&%N @@ -436,13 +420,47 @@ If the input format is .Xr man 7 , the input is copied to the output, expanding any .Xr roff 7 -.Sq so +.Ic so requests. The parser is also run, and as usual, the .Fl W level controls which .Sx DIAGNOSTICS are displayed before copying the input to the output. +.Ss Markdown Output +Translate +.Xr mdoc 7 +input to the +.Sy markdown +format conforming to +.Lk http://daringfireball.net/projects/markdown/syntax.text\ + "John Gruber's 2004 specification" . +The output also almost conforms to the +.Lk http://commonmark.org/ CommonMark +specification. +.Pp +The character set used for the markdown output is ASCII. +Non-ASCII characters are encoded as HTML entities. +Since that is not possible in literal font contexts, because these +are rendered as code spans and code blocks in the markdown output, +non-ASCII characters are transliterated to ASCII approximations in +these contexts. +.Pp +Markdown is a very weak markup language, so all semantic markup is +lost, and even part of the presentational markup may be lost. +Do not use this as an intermediate step in converting to HTML; +instead, use +.Fl T Cm html +directly. +.Pp +The +.Xr man 7 , +.Xr tbl 7 , +and +.Xr eqn 7 +input languages are not supported by +.Fl T Cm markdown +output mode. .Ss PDF Output PDF-1.1 output may be generated by .Fl T Cm pdf . @@ -498,7 +516,15 @@ Use to show a human readable representation of the syntax tree. It is useful for debugging the source code of manual pages. The exact format is subject to change, so don't write parsers for it. -Each output line shows one syntax tree node. +.Pp +The first paragraph shows meta data found in the +.Xr mdoc 7 +prologue, on the +.Xr man 7 +.Ic \&TH +line, or the fallbacks used. +.Pp +In the tree dump, each output line shows one syntax tree node. Child nodes are indented with respect to their parent node. The columns are: .Pp @@ -530,6 +556,8 @@ A closing parenthesis if the node is a closing delimit .It A full stop if the node ends a sentence. .It +BROKEN if the node is a block broken by another block. +.It NOSRC if the node is not in the input file, but automatically generated from macros. .It @@ -537,13 +565,32 @@ NOPRT if the node is not supposed to generate output for any output format. .El .El +.Pp +The following +.Fl O +argument is accepted: +.Bl -tag -width Ds +.It Cm noval +Skip validation and show the unvalidated syntax tree. +This can help to find out whether a given behaviour is caused by +the parser or by the validator. +Meta data is not available in this case. +.El .Sh ENVIRONMENT .Bl -tag -width MANPAGER .It Ev MANPAGER Any non-empty value of the environment variable .Ev MANPAGER -will be used instead of the standard pagination program, -.Xr more 1 . +is used instead of the standard pagination program, +.Xr more 1 ; +see +.Xr man 1 +for details. +Only used if +.Fl a +or +.Fl l +is specified. .It Ev PAGER Specifies the pagination program to use when .Ev MANPAGER @@ -551,7 +598,12 @@ is not defined. If neither PAGER nor MANPAGER is defined, .Xr more 1 .Fl s -will be used. +is used. +Only used if +.Fl a +or +.Fl l +is specified. .El .Sh EXIT STATUS The @@ -849,6 +901,14 @@ The .Ic \&Nd macro lacks the required argument. The title line of the manual will end after the dash. +.It Sy "description line outside NAME section" +.Pq mdoc +An +.Ic \&Nd +macro appears outside the NAME section. +The arguments are printed anyway and the following text is used for +.Xr apropos 1 , +but none of that behaviour is portable. .It Sy "sections out of conventional order" .Pq mdoc A standard section occurs after another section it usually precedes. @@ -1349,6 +1409,10 @@ it is hard to predict which tab stop position the tab Whitespace at the end of input lines is almost never semantically significant \(em but in the odd case where it might be, it is extremely confusing when reviewing and maintaining documents. +.It Sy "new sentence, new line" +.Pq mdoc +A new sentence starts in the middle of a text line. +Start it on a new input line to help formatters produce correct spacing. .It Sy "bad comment style" .Pq roff Comment lines start with a dot, a backslash, and a double-quote character. @@ -1824,6 +1888,19 @@ as if they were a text line. .Xr mdoc 7 , .Xr roff 7 , .Xr tbl 7 +.Sh HISTORY +The +.Nm +utility first appeared in +.Ox 4.8 . +The option +.Fl I +appeared in +.Ox 5.2 , +and +.Fl aCcfhKklMSsw +in +.Ox 5.7 . .Sh AUTHORS .An -nosplit The @@ -1832,12 +1909,3 @@ utility was written by .An Kristaps Dzonsons Aq Mt kristaps@bsd.lv and is maintained by .An Ingo Schwarze Aq Mt schwarze@openbsd.org . -.Sh BUGS -In -.Fl T Cm html , -the maximum size of an element attribute is determined by -.Dv BUFSIZ , -which is usually 1024 bytes. -Be aware of this when setting long link -formats such as -.Fl O Cm style Ns = Ns Ar really/long/link .