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.
Move mandoc_hyph() into roff_parsetext() as a single conditional. While
here, do some function renames for clarity and make all function
prototypes be in one place.
First, roff_res() has no need to invoke ROFF_RERUN: since it's executed
before any other roff processing occurs, it's Ok to just let it do its
thing and pass through. Also, make sure this function is ALWAYS called,
not just when first_string is defined.
Second, add a new function, roff_parsetext(), that post-processes
non-macro lines. This, for the time being, amounts to detecting soft
hyphens. This fixes a long-standing bug in that -man now has proper
hyphen breaking!
Move checking of escapes into roff.c, where we're already stepping
through looking for user-defined escapes. This clears up a nice bit of
validation code.
Implement the first steps of equation parsing from within libmdoc.
This consists of a shim around the text parser that calls out to libroff
if equation components exist on the line. Right now this will do
nothing, as the equation delimiter always returns nil.
Scary-looking but otherwise harmless changes allow me to build for Windows.
That is to say, with mingw32. This amounts to the following:
(1) break compat.c into compat_strlcpy.c and compat_strlcat.c
(2) add compat_getsubopt.c (from OpenBSD) and test-getsubopt.c
(3) add test-strptime.c for HAVE_STRPTIME
(4) add ifdef bits here and there, where necessary
(5) remove some harmless unportable stuff (u_char, localtime_r)
I've added the appropriate mdocml.zip target to the Makefile, too.
Add support for tdefine and ndefine. Consolidate some error messages. Add
somem more version notes (getting there). Have the equation nanme be captured.