Get ready for version. I'm bumping the minor release to 1.12 because
this involves both a major functionality addition (-Tman), a new utility
(apropos), and both apropos and mandocdb being built by default.
Tidy up -Tman output. This has NO functional change: (1) introduced a
state struct instead of using global statics; (2) documented throughout
the file; (3) fixed a situation of reaching past the end of our buffer
for zero-length strings; (4) alpha-ordered the functions. (1) and (3)
ok schwarze@. (2) and (4) are purely style and documentation.
Clean up file a bit: remove errx and err function pointers from the
state struct (directly using fprintf and perror to do this); add some
in-line documentation; remove state init and destroy directly to the
main function.
Import apropos from mandoc-tools after inlining all source files
(originally including extern.h, state.c, and sort.c). The apropos
utility interfaces with the databases of mandocdb to provide semantic
searching capabilities. It Works For Me, but will need lots of cleanup
in the coming months.
If -Tman is specified and input is -man, echo the preprocessed (`so'
replaced by file) input. This replaces earlier behaviour of doing
nothing, which I found unexpected (mandoc should always output).
This requires a buffer in read.c that saves the input lines before being
parsed, with a special hook if `so' is invoked. This buffer is just
flushed to output if -mman is the input.
While mucking around doing this, I also alpha-ordered the mandoc.h
functions.
Ok schwarze@, with no screaming when the polished patch was published.
Add the -Ofragment option to -T[]x]html. This accomodates for embedding
manual output in existing HTML or XHTML documents, e.g., when invoking
mandoc from an SSI or CGI.
Make -T[x]html suppress output with \& (and similar zwsp points). This
fixes lynx's rendering of manuals with the \&, which were rendering as
​ in the text. Reported by Paul de Weerd, thanks!
implement .Ap .Bd .Bo .Bq .D1 .Ic .Lp .Oo .Pf .Po .Ss .Sx .Sy .br .sp
implement .Bl -bullet
add more information to the .TH line
escape dots at the beginnings of lines
add trailing newline character at the end of the file
do not misinterpret the ROOT block as .Ap
1) Move the LANGUAGE SYNTAX from mdoc(7) and man(7) to roff(7),
it's common to both and it's actually roff syntax.
2) Move the MACRO SYNTAX down to the bottom, such that the less
technical parts MANUAL STRUCTURE and MACRO OVERVIEW get to the top.
Getting everything to again fit together after the reshuffling
required various adjustments; also adjust and improve
the DESCRIPTIONS while there.
As noticed by kristaps@, when breaking an overflowing line,
forget about pending whitespace (vbl), or the next line would
be misaligned and potentially too long; but i'm fixing this
in a simpler way than he proposed.
Also remove the kludges in .HP that compensated for this bug.
Using user-defined macros, surprisingly, it is possible
to have *next*-line head arguments on the *same* input line.
So .TP must not assume that a head argument with a matching
input line number is a same-line argument (and access a NULL pointer).
Bug found and fix tested by kristaps@ with groff_hdtbl(7).
When advancing the left margin, .RS also needs to reset the right margin
to the default and check that the left does not outgrow the right one.
Otherwise, the (rmargin >= offset) assertion fails in term_flushln().
Bug found and fix tested by kristaps@ with NetBSD slapo-retcode(5).
Sync print_mdoc_head to print_man_head;
this was forgotten after man_term.c rev. 1.25 on March 2, 2010.
The benefit is a sane page header line when .Dt is very long.
Reminded by Thomas Klausner <wiz at NetBSD>, thanks.
In columnated contexts (.Bl -column, .Bl -tag, .IP, .TP, .HP etc.), do not
pad after writing a column. Instead, always pad before writing content.
In itself, this change avoids:
- writing trailing whitespace in some situations
- with .fi/.nf in .HP, breaking lines that were already padded
It allows several bugfixes included in this patch:
- Do not count backspace as a character with positive width.
- Set up proper indentation when encountering .fi/.nf in .HP.
- Adjust the .HP indentation width to what groff does.
- Never unlimit the right margin unless in the final column.
Fix another regression introduced in 1.11.7:
If a string is defined in terms of itself, the REPARSE_LIMIT in read.c
used to break the cycle. This no longer works since all the work
is now done in the function roff_res(), looping indefinitely.
Make this loop finite by arbitrarily limiting the number of times one
string may be expanded; when that limit is reached, leave the remaining
string references unexpanded.
This changes behaviour compared to 1.11.5, where the whole line would
have been dropped. The new behaviour is better because it loses less
information. We don't want to imitate groff-1.20.1 behaviour anyway
because groff aborts parsing of the whole file.
This patch was originally written in July 2011 by kristaps@,
i promptly committed it to OpenBSD, and then it was forgotten.
Now i rediscovered it when merging 1.11.7 to OpenBSD.
Add a MACRO OVERVIEW, listing all macros ordered by purpose,
each with a one-line discription. Use this when wondering
which macro fits best for your particular use case, and whether
there are alternatives.
feedback ond ok jmc@, ok kristaps@
Initial, incomplete support for -Tman
to convert mdoc(7) documents to the man(7) language.
This is work in progress and will be developed in tree.
It does already handle the cat(1) manual,
but will hardly handle all your fancy manuals yet.
go ahead kristaps@ jmc@ millert@ deraadt@
Teach -man that a literal context should be closed by SS/SH in the
backend (the front-end already accomodated for this). Found indirectly
from a question by Brad Smith.
Finishing touches on demandoc. It now backs over ending punctuation as
well as leading punctuation. Again, this isn't the same as deroff
(which uses, I think, some punctuation as delimiters), but it's easier
to explain and simpler to audit.
Make `-w' mode work much better. This is INCREDIBLY poorly specified in
any other deroff manual, and as I don't think anybody actually uses
deroff, I don't feel compelled to research its behaviour too much and
can just do what's logical.
First, use \(dq instead of \*q for double-quote. Second, use `Li' to
note literal text in "Examples:" parts. Finally, move parts of
Quotation related to keeping whitespace into Whitespace and clean up the
text to be a bit clearer. Examples can be added back in at will, but
now it follows the general layout of explanation followed by examples.
Align `-offset indent' and `D1' by forcing BLOCKQUOTE to have a 5ex
margin. This is dubious: the HTML4 spec specifically says that
BLOCKQUOTE shouldn't be abused for indentation, which is exactly what we
do. However, `D1' needs indentation and it's the only way to force text
browsers to do so. Alternatives?
Also remove the unused HALFINDENT defines while here.
Have `Li' be correctly monospaced in -T[x]html. Also make sure that
`Li' prints as a CODE tag and the style-sheet has the `lit' class apply
to multiple tag types.
Sync man.7's LANGUAGE SYNTAX (was INPUT ENCODING) with mdoc.7.
While here, fix the scaling widths example that incorrectly used `br'
(it now correctly uses `sp').
Ingo Schwarze [Tue, 16 Aug 2011 23:44:58 +0000 (23:44 +0000)]
Replace the .Fl examples by others exhibiting the same features,
but avoiding use of .Nm, because letting .Nm call other macros
is unusual style, and we don't want unusual style in examples.
Issue brought up by kristaps@.
Fixed mingw compatibility where the "z" printf() modifier isn't
recognised. It's easier to make these u_int than to jump through hoops
for a special formatter.
Allow `Sx' and `Ss' to have child nodes. Fixes manuals in NetBSD.
Originally pointed out by joerg@ then again by Thomas Klausner by way of
Nicolas Joy. Note: don't use these constructions as you can't link to
the sections with `Sx'.
Ingo Schwarze [Wed, 3 Aug 2011 21:25:23 +0000 (21:25 +0000)]
Add small chunks of new text and better examples written from scratch,
filling gaps found by checking the MANUAL DOMAIN chapter in mdoc.samples(7).
While here, fix lots of minor issues.
feedback and ok jmc@
Ingo Schwarze [Tue, 2 Aug 2011 01:07:26 +0000 (01:07 +0000)]
The term "reserved terms" is too broad, so narrow it down
to "delimiters", and explain which special handling they get
as macro arguments. Move the text to a better place and remove
a few lies. Postpone figuring out the lists of macros causing
that special handling, it would cost too much time right now.
feedback and ok jmc@
This also brings the file back in sync with OpenBSD.
Ingo Schwarze [Mon, 1 Aug 2011 07:45:11 +0000 (07:45 +0000)]
Add some new text written from scratch after checking whether anything
explained in mdoc.samples(7) is missing from mdoc(7):
* Discourage trailing whitespace.
* Move all information about quoted arguments to the relevant
subsection, shortening it a bit, and adding an example.
* Mention that blanks can be quoted with a backslash.
* A better .Nd line in the template (verbatim from mdoc.samples(7)).
* Explain how to escape callable macro names, and provide examples.
ok jmc@
trivial fixes found while merging to OpenBSD:
* ellipsis is an argument to .Ar, not part of the preceding argument
* libz, libpam, on, off are not placeholders for arguments
* .Rv is not only relevant for system calls, see atexit(3), sem_init(3)
Make sure that in -Tascii mode, predefined strings render the same
way as in groff. With this fix, \*(If, \*(Pi and \*(Tm change in
other output modes, but -Tascii is what matters.
Found when merging 1.11.3 to OpenBSD; ok kristaps@.
Regression fixes after merging 1.11.3 to OpenBSD (rev. 1.20):
* Do not pass integers outside the ASCII range to isprint().
* Make sure escaped characters are really printed verbatim
when the escape sequence has no special meaning.
ok kristaps@
An implementation of `tr'. This routes allocations of TEXT nodes
through libroff, which does the appropriate translations of `tr'. This
is SLOW: it uses the backend of `ds' and `de', which is a simple linear
list. However, unlike `ds' and `de', it iterates over EACH CHARACTER of
the entire file looking for replacements.