From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=UNPARSEABLE_RELAY,URIBL_SBL, URIBL_SBL_A autolearn=no autolearn_force=no version=3.4.2 Received: (qmail 24032 invoked from network); 19 Apr 2020 16:36:55 -0000 Received: from bsd.lv (HELO mandoc.bsd.lv) (66.111.2.12) by inbox.vuxu.org with UTF8ESMTPZ; 19 Apr 2020 16:36:55 -0000 Received: from fantadrom.bsd.lv (localhost [127.0.0.1]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id f9e16051 for ; Sun, 19 Apr 2020 11:36:53 -0500 (EST) Received: from localhost (mandoc.bsd.lv [local]) by mandoc.bsd.lv (OpenSMTPD) with ESMTPA id 64fc581b for ; Sun, 19 Apr 2020 11:36:53 -0500 (EST) Date: Sun, 19 Apr 2020 11:36:53 -0500 (EST) X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: mandoc: When .Bd, .D1, or .Dl is tagged, attach the permalink to the X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: <8a57be402a7a9846@mandoc.bsd.lv> Log Message: ----------- When .Bd, .D1, or .Dl is tagged, attach the permalink to the first few letters, similar to what was earlier done for .Pp. Modified Files: -------------- mandoc: tag.c mandoc/regress/mdoc/Bd: Makefile nested.in nested.out_ascii nested.out_lint nested.out_markdown nested.out_tag paragraph.in paragraph.out_ascii paragraph.out_html paragraph.out_markdown mandoc/regress/mdoc/D1: spacing.out_html mandoc/regress/mdoc/Dl: Makefile spacing.in spacing.out_ascii spacing.out_lint spacing.out_markdown spacing.out_tag mandoc/regress/mdoc/Pp: arg.out_markdown mandoc/regress/mdoc/blank: transp.out_markdown Added Files: ----------- mandoc/regress/mdoc/Bd: nested.out_html spacing.out_tag mandoc/regress/mdoc/Dl: spacing.out_html Revision Data ------------- Index: Makefile =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Dl/Makefile,v retrieving revision 1.4 retrieving revision 1.5 diff -Lregress/mdoc/Dl/Makefile -Lregress/mdoc/Dl/Makefile -u -p -r1.4 -r1.5 --- regress/mdoc/Dl/Makefile +++ regress/mdoc/Dl/Makefile @@ -1,7 +1,8 @@ -# $OpenBSD: Makefile,v 1.5 2020/04/06 09:55:49 schwarze Exp $ +# $OpenBSD: Makefile,v 1.6 2020/04/19 16:26:11 schwarze Exp $ REGRESS_TARGETS = spacing TAG_TARGETS = spacing LINT_TARGETS = spacing +HTML_TARGETS = spacing .include Index: spacing.out_lint =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Dl/spacing.out_lint,v retrieving revision 1.6 retrieving revision 1.7 diff -Lregress/mdoc/Dl/spacing.out_lint -Lregress/mdoc/Dl/spacing.out_lint -u -p -r1.6 -r1.7 --- regress/mdoc/Dl/spacing.out_lint +++ regress/mdoc/Dl/spacing.out_lint @@ -1 +1 @@ -mandoc: spacing.in:13:2: WARNING: empty block: Dl +mandoc: spacing.in:15:2: WARNING: empty block: Dl Index: spacing.out_ascii =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Dl/spacing.out_ascii,v retrieving revision 1.3 retrieving revision 1.4 diff -Lregress/mdoc/Dl/spacing.out_ascii -Lregress/mdoc/Dl/spacing.out_ascii -u -p -r1.3 -r1.4 --- regress/mdoc/Dl/spacing.out_ascii +++ regress/mdoc/Dl/spacing.out_ascii @@ -4,9 +4,13 @@ NNAAMMEE DDll--ssppaacciinngg - spacing in and around one-line literal displays DDEESSCCRRIIPPTTIIOONN + BEGINTEST + preceding text spacing in and around one-line literal displays empty display: following text + ENDTEST + end of file -OpenBSD April 6, 2020 OpenBSD +OpenBSD April 19, 2020 OpenBSD --- /dev/null +++ regress/mdoc/Dl/spacing.out_html @@ -0,0 +1,8 @@ +

preceding text

+
+ in and around one-line literal displays
+empty display: +
+following text +
Index: spacing.in =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Dl/spacing.in,v retrieving revision 1.3 retrieving revision 1.4 diff -Lregress/mdoc/Dl/spacing.in -Lregress/mdoc/Dl/spacing.in -u -p -r1.3 -r1.4 --- regress/mdoc/Dl/spacing.in +++ regress/mdoc/Dl/spacing.in @@ -1,4 +1,4 @@ -.\" $OpenBSD: spacing.in,v 1.5 2020/04/06 09:55:49 schwarze Exp $ +.\" $OpenBSD: spacing.in,v 1.6 2020/04/19 16:26:11 schwarze Exp $ .Dd $Mdocdate$ .Dt DL-SPACING 1 .Os @@ -6,9 +6,15 @@ .Nm Dl-spacing .Nd spacing in and around one-line literal displays .Sh DESCRIPTION +BEGINTEST +.Pp preceding text .Tg display .Dl spacing in and around one-line literal displays empty display: .Dl following text +.br +ENDTEST +.br +end of file Index: spacing.out_markdown =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Dl/spacing.out_markdown,v retrieving revision 1.3 retrieving revision 1.4 diff -Lregress/mdoc/Dl/spacing.out_markdown -Lregress/mdoc/Dl/spacing.out_markdown -u -p -r1.3 -r1.4 --- regress/mdoc/Dl/spacing.out_markdown +++ regress/mdoc/Dl/spacing.out_markdown @@ -6,12 +6,16 @@ DL-SPACING(1) - General Commands Manual # DESCRIPTION +BEGINTEST + preceding text spacing in and around one-line literal displays empty display: -following text +following text +ENDTEST +end of file -OpenBSD - April 6, 2020 +OpenBSD - April 19, 2020 Index: spacing.out_tag =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Dl/spacing.out_tag,v retrieving revision 1.1 retrieving revision 1.2 diff -Lregress/mdoc/Dl/spacing.out_tag -Lregress/mdoc/Dl/spacing.out_tag -u -p -r1.1 -r1.2 --- regress/mdoc/Dl/spacing.out_tag +++ regress/mdoc/Dl/spacing.out_tag @@ -1,3 +1,3 @@ NAME 3 DESCRIPTION 6 -display 8 +display 10 Index: arg.out_markdown =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Pp/arg.out_markdown,v retrieving revision 1.4 retrieving revision 1.5 diff -Lregress/mdoc/Pp/arg.out_markdown -Lregress/mdoc/Pp/arg.out_markdown -u -p -r1.4 -r1.5 --- regress/mdoc/Pp/arg.out_markdown +++ regress/mdoc/Pp/arg.out_markdown @@ -15,8 +15,7 @@ line 3 line 4 -final -text +final text ENDTEST Index: tag.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/tag.c,v retrieving revision 1.35 retrieving revision 1.36 diff -Ltag.c -Ltag.c -u -p -r1.35 -r1.36 --- tag.c +++ tag.c @@ -43,6 +43,8 @@ struct tag_entry { char s[]; }; +static void tag_move_href(struct roff_man *, + struct roff_node *, const char *); static void tag_move_id(struct roff_node *); static struct ohash tag_data; @@ -254,6 +256,39 @@ tag_move_id(struct roff_node *n) } /* + * When a paragraph is tagged and starts with text, + * move the permalink to the first few words. + */ +static void +tag_move_href(struct roff_man *man, struct roff_node *n, const char *tag) +{ + char *cp; + + if (n == NULL || n->type != ROFFT_TEXT || + *n->string == '\0' || *n->string == ' ') + return; + + cp = n->string; + while (cp != NULL && cp - n->string < 5) + cp = strchr(cp + 1, ' '); + + /* If the first text node is longer, split it. */ + + if (cp != NULL && cp[1] != '\0') { + man->last = n; + man->next = ROFF_NEXT_SIBLING; + roff_word_alloc(man, n->line, + n->pos + (cp - n->string), cp + 1); + man->last->flags = n->flags & ~NODE_LINE; + *cp = '\0'; + } + + assert(n->tag == NULL); + n->tag = mandoc_strdup(tag); + n->flags |= NODE_HREF; +} + +/* * When all tags have been set, decide where to put * the associated permalinks, and maybe move some tags * to the beginning of the respective paragraphs. @@ -261,34 +296,16 @@ tag_move_id(struct roff_node *n) void tag_postprocess(struct roff_man *man, struct roff_node *n) { - struct roff_node *nn; - char *cp; - if (n->flags & NODE_ID) { switch (n->tok) { case MDOC_Pp: - nn = n->next; - if (nn == NULL || nn->type != ROFFT_TEXT || - *nn->string == '\0' || *nn->string == ' ') - break; - /* Use the first few letters for the permalink. */ - cp = nn->string; - while (cp != NULL && cp - nn->string < 5) - cp = strchr(cp + 1, ' '); - if (cp != NULL && cp[1] != '\0') { - /* Split a longer text node. */ - man->last = nn; - man->next = ROFF_NEXT_SIBLING; - roff_word_alloc(man, nn->line, - nn->pos + (cp - nn->string), cp + 1); - man->last->flags = nn->flags; - *cp = '\0'; - } - assert(nn->tag == NULL); - nn->tag = mandoc_strdup(n->tag); - nn->flags |= NODE_HREF; + tag_move_href(man, n->next, n->tag); break; case MDOC_Bd: + case MDOC_D1: + case MDOC_Dl: + tag_move_href(man, n->child, n->tag); + break; case MDOC_Bl: /* XXX No permalink for now. */ break; --- /dev/null +++ regress/mdoc/Bd/nested.out_html @@ -0,0 +1,28 @@ +

regular text

+
text + (default indent) +
text + (default indent)
+outer text
+regular text +
text + (4n) +
text + (2n)
+outer text +
+
tag
+
text
+
+outer text
+regular text +
+
tag
+
outer text +
inner text (2n)
+ outer text
+
Index: paragraph.out_html =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Bd/paragraph.out_html,v retrieving revision 1.4 retrieving revision 1.5 diff -Lregress/mdoc/Bd/paragraph.out_html -Lregress/mdoc/Bd/paragraph.out_html -u -p -r1.4 -r1.5 --- regress/mdoc/Bd/paragraph.out_html +++ regress/mdoc/Bd/paragraph.out_html @@ -1,6 +1,7 @@

paragraph

-
filled display +
+ display

in display

@@ -8,10 +9,10 @@ back to normal

another paragraph

-unfilled
+ literal
 display
 
-
+ literal
 paragraph
 
Index: paragraph.out_ascii =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Bd/paragraph.out_ascii,v retrieving revision 1.2 retrieving revision 1.3 diff -Lregress/mdoc/Bd/paragraph.out_ascii -Lregress/mdoc/Bd/paragraph.out_ascii -u -p -r1.2 -r1.3 --- regress/mdoc/Bd/paragraph.out_ascii +++ regress/mdoc/Bd/paragraph.out_ascii @@ -15,13 +15,13 @@ DDEESSCCRRIIPPTTIIOONN another paragraph - unfilled + unfilled literal display - unfilled + unfilled literal paragraph again back to normal ENDTEST end of file -OpenBSD April 6, 2020 OpenBSD +OpenBSD April 19, 2020 OpenBSD Index: nested.in =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Bd/nested.in,v retrieving revision 1.3 retrieving revision 1.4 diff -Lregress/mdoc/Bd/nested.in -Lregress/mdoc/Bd/nested.in -u -p -r1.3 -r1.4 --- regress/mdoc/Bd/nested.in +++ regress/mdoc/Bd/nested.in @@ -1,4 +1,4 @@ -.\" $OpenBSD: nested.in,v 1.3 2020/04/06 09:55:49 schwarze Exp $ +.\" $OpenBSD: nested.in,v 1.4 2020/04/19 16:26:11 schwarze Exp $ .Dd $Mdocdate$ .Dt BD-NESTED 1 .Os @@ -6,16 +6,18 @@ .Nm Bd-nested .Nd nested displays and lists .Sh DESCRIPTION +BEGINTEST +.Pp regular text .Tg outer .Bd -ragged -offset indent -outer -text (default indent) +outer text +.Pq default indent .Tg inner .Bd -ragged -offset indent -inner -text (default indent) +inner text +.Pq default indent .Ed outer text @@ -45,3 +47,4 @@ inner text (2n) .Ed outer text .El +ENDTEST Index: nested.out_markdown =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Bd/nested.out_markdown,v retrieving revision 1.3 retrieving revision 1.4 diff -Lregress/mdoc/Bd/nested.out_markdown -Lregress/mdoc/Bd/nested.out_markdown -u -p -r1.3 -r1.4 --- regress/mdoc/Bd/nested.out_markdown +++ regress/mdoc/Bd/nested.out_markdown @@ -6,14 +6,16 @@ BD-NESTED(1) - General Commands Manual # DESCRIPTION +BEGINTEST + regular text -> outer -> text (default indent) +> outer text +> (default indent) -> > inner -> > text (default indent) +> > inner text +> > (default indent) > outer > text @@ -43,4 +45,6 @@ tag > outer text -OpenBSD - April 6, 2020 +ENDTEST + +OpenBSD - April 19, 2020 Index: Makefile =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Bd/Makefile,v retrieving revision 1.6 retrieving revision 1.7 diff -Lregress/mdoc/Bd/Makefile -Lregress/mdoc/Bd/Makefile -u -p -r1.6 -r1.7 --- regress/mdoc/Bd/Makefile +++ regress/mdoc/Bd/Makefile @@ -1,12 +1,12 @@ -# $OpenBSD: Makefile,v 1.23 2020/04/06 09:55:49 schwarze Exp $ +# $OpenBSD: Makefile,v 1.24 2020/04/19 16:26:11 schwarze Exp $ REGRESS_TARGETS = beforeNAME blank centered nested nf paragraph spacing REGRESS_TARGETS += badargs empty offset-empty offset-neg REGRESS_TARGETS += break broken unclosed -TAG_TARGETS = nested paragraph +TAG_TARGETS = nested paragraph spacing LINT_TARGETS = beforeNAME blank nested badargs break broken unclosed -HTML_TARGETS = nf paragraph +HTML_TARGETS = nested nf paragraph SKIP_TMAN = beforeNAME centered Index: nested.out_lint =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Bd/nested.out_lint,v retrieving revision 1.6 retrieving revision 1.7 diff -Lregress/mdoc/Bd/nested.out_lint -Lregress/mdoc/Bd/nested.out_lint -u -p -r1.6 -r1.7 --- regress/mdoc/Bd/nested.out_lint +++ regress/mdoc/Bd/nested.out_lint @@ -1,2 +1,2 @@ -mandoc: nested.in:16:2: WARNING: nested displays are not portable: Bd in Bd -mandoc: nested.in:29:2: WARNING: nested displays are not portable: Bd in Bd +mandoc: nested.in:18:2: WARNING: nested displays are not portable: Bd in Bd +mandoc: nested.in:31:2: WARNING: nested displays are not portable: Bd in Bd Index: nested.out_ascii =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Bd/nested.out_ascii,v retrieving revision 1.3 retrieving revision 1.4 diff -Lregress/mdoc/Bd/nested.out_ascii -Lregress/mdoc/Bd/nested.out_ascii -u -p -r1.3 -r1.4 --- regress/mdoc/Bd/nested.out_ascii +++ regress/mdoc/Bd/nested.out_ascii @@ -4,6 +4,8 @@ NNAAMMEE BBdd--nneesstteedd - nested displays and lists DDEESSCCRRIIPPTTIIOONN + BEGINTEST + regular text outer text (default indent) @@ -25,5 +27,6 @@ DDEESSCCRRIIPPTTIIOONN inner text (2n) outer text + ENDTEST -OpenBSD April 6, 2020 OpenBSD +OpenBSD April 19, 2020 OpenBSD --- /dev/null +++ regress/mdoc/Bd/spacing.out_tag @@ -0,0 +1,4 @@ +NAME 3 +DESCRIPTION 6 +EXAMPLES 14 +word 15 Index: nested.out_tag =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Bd/nested.out_tag,v retrieving revision 1.1 retrieving revision 1.2 diff -Lregress/mdoc/Bd/nested.out_tag -Lregress/mdoc/Bd/nested.out_tag -u -p -r1.1 -r1.2 --- regress/mdoc/Bd/nested.out_tag +++ regress/mdoc/Bd/nested.out_tag @@ -1,6 +1,6 @@ NAME 3 DESCRIPTION 6 -outer 9 -inner 11 -outer 15 -inner 17 +outer 11 +inner 13 +outer 17 +inner 19 Index: paragraph.in =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Bd/paragraph.in,v retrieving revision 1.2 retrieving revision 1.3 diff -Lregress/mdoc/Bd/paragraph.in -Lregress/mdoc/Bd/paragraph.in -u -p -r1.2 -r1.3 --- regress/mdoc/Bd/paragraph.in +++ regress/mdoc/Bd/paragraph.in @@ -1,4 +1,4 @@ -.\" $OpenBSD: paragraph.in,v 1.2 2020/04/06 09:55:49 schwarze Exp $ +.\" $OpenBSD: paragraph.in,v 1.3 2020/04/19 16:26:11 schwarze Exp $ .Dd $Mdocdate$ .Dt BD-PARAGRAPH 1 .Os @@ -28,12 +28,12 @@ to normal another paragraph .Tg unfilled -.Bd -unfilled -unfilled +.Bd -literal +unfilled literal display .Tg upara .Pp -unfilled +unfilled literal paragraph .Ed again back Index: paragraph.out_markdown =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Bd/paragraph.out_markdown,v retrieving revision 1.2 retrieving revision 1.3 diff -Lregress/mdoc/Bd/paragraph.out_markdown -Lregress/mdoc/Bd/paragraph.out_markdown -u -p -r1.2 -r1.3 --- regress/mdoc/Bd/paragraph.out_markdown +++ regress/mdoc/Bd/paragraph.out_markdown @@ -25,10 +25,10 @@ to normal another paragraph - unfilled + unfilled literal display - unfilled + unfilled literal paragraph again back @@ -36,4 +36,4 @@ to normal ENDTEST end of file -OpenBSD - April 6, 2020 +OpenBSD - April 19, 2020 Index: spacing.out_html =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/D1/spacing.out_html,v retrieving revision 1.3 retrieving revision 1.4 diff -Lregress/mdoc/D1/spacing.out_html -Lregress/mdoc/D1/spacing.out_html -u -p -r1.3 -r1.4 --- regress/mdoc/D1/spacing.out_html +++ regress/mdoc/D1/spacing.out_html @@ -1,7 +1,7 @@

preceding paragraph

+ Bd-indent" id="display"> in + and around one-line displays
empty display:
following text Index: transp.out_markdown =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/blank/transp.out_markdown,v retrieving revision 1.2 retrieving revision 1.3 diff -Lregress/mdoc/blank/transp.out_markdown -Lregress/mdoc/blank/transp.out_markdown -u -p -r1.2 -r1.3 --- regress/mdoc/blank/transp.out_markdown +++ regress/mdoc/blank/transp.out_markdown @@ -23,8 +23,7 @@ Pp sp 2v: sp Pp: -Double -sp: +Double sp: br blank: -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv