Hi Klemens,
Klemens Nanni wrote on Fri, Mar 20, 2020 at 12:12:39AM +0100:
> In both command line usage and manual output format, find's options
> and primaries behave the same,
Not really. In the POSIX sense, options are indeed options while
primaries are arguments. That has implications, for example that
all options must precede all primaries.
> but their mdoc(7) markup is different
I don't feel very strongly about that, but i think .Cm does make
slightly more sense for primaries than .Fl (and .Ic is probably
acceptable, too, even though .Cm might be better because these are
command line arguments, not stand-alone commands).
> and therefore causes different tag names:
>
> -x (option) can be looked up with ":tx<Enter>" in the manual pager,
> whereas -amin (primary) requires ":t-amin<Enter>" including the dash.
>
> I'd like primaries to behave the same like options when it comes to
> tags in manuals, is that a reasonable expectation?
I think that is reasonable, yes. I think it makes sense to consider
tags as words, i.e. strings that usually consist of letters and may
sometimes contain digits, but never contain whitespace and usually
do not start with punctuation characters. I'm not sure this rule of
thumb can be made very strict, but i think it is possible to polish
this by handling a small number of common cases. For example,
automatic tagging in man(7) already discards leading whitespace,
some escape sequences, and leading dashes from tags. Automatic
tagging in mdoc(7) already discards leading zero-width spaces
and leading backslashes. I think it would make sense to also
skip leading dashes here, see the patch below.
Do you agree with that?
Yours,
Ingo
Index: tag.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/tag.c,v
retrieving revision 1.29
diff -u -p -r1.29 tag.c
--- tag.c 13 Mar 2020 16:14:14 -0000 1.29
+++ tag.c 20 Mar 2020 15:50:33 -0000
@@ -87,8 +87,24 @@ tag_put(const char *s, int prio, struct
if (n->child == NULL || n->child->type != ROFFT_TEXT)
return;
s = n->child->string;
- if (s[0] == '\\' && (s[1] == '&' || s[1] == 'e'))
- s += 2;
+ switch (s[0]) {
+ case '-':
+ s++;
+ break;
+ case '\\':
+ switch (s[1]) {
+ case '&':
+ case '-':
+ case 'e':
+ s += 2;
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
}
/*