version 1.381, 2020/04/01 20:21:08 |
version 1.386, 2020/04/24 12:02:33 |
|
|
#include "mandoc.h" |
#include "mandoc.h" |
#include "mandoc_xr.h" |
#include "mandoc_xr.h" |
#include "roff.h" |
#include "roff.h" |
#include "tag.h" |
|
#include "mdoc.h" |
#include "mdoc.h" |
#include "libmandoc.h" |
#include "libmandoc.h" |
#include "roff_int.h" |
#include "roff_int.h" |
#include "libmdoc.h" |
#include "libmdoc.h" |
|
#include "tag.h" |
|
|
/* FIXME: .Bl -diag can't have non-text children in HEAD. */ |
/* FIXME: .Bl -diag can't have non-text children in HEAD. */ |
|
|
Line 1105 post_tg(POST_ARGS) |
|
Line 1105 post_tg(POST_ARGS) |
|
struct roff_node *n; /* The .Tg node. */ |
struct roff_node *n; /* The .Tg node. */ |
struct roff_node *nch; /* The first child of the .Tg node. */ |
struct roff_node *nch; /* The first child of the .Tg node. */ |
struct roff_node *nn; /* The next node after the .Tg node. */ |
struct roff_node *nn; /* The next node after the .Tg node. */ |
|
struct roff_node *np; /* The parent of the next node. */ |
struct roff_node *nt; /* The TEXT node containing the tag. */ |
struct roff_node *nt; /* The TEXT node containing the tag. */ |
size_t len; /* The number of bytes in the tag. */ |
size_t len; /* The number of bytes in the tag. */ |
|
|
Line 1150 post_tg(POST_ARGS) |
|
Line 1151 post_tg(POST_ARGS) |
|
} |
} |
|
|
/* By default, tag the .Tg node itself. */ |
/* By default, tag the .Tg node itself. */ |
if (nn == NULL) |
if (nn == NULL || nn->flags & NODE_ID) |
nn = n; |
nn = n; |
|
|
/* Explicit tagging of specific macros. */ |
/* Explicit tagging of specific macros. */ |
Line 1158 post_tg(POST_ARGS) |
|
Line 1159 post_tg(POST_ARGS) |
|
case MDOC_Sh: |
case MDOC_Sh: |
case MDOC_Ss: |
case MDOC_Ss: |
case MDOC_Fo: |
case MDOC_Fo: |
nn = nn->head; |
nn = nn->head->child == NULL ? n : nn->head; |
/* FALLTHROUGH */ |
break; |
|
case MDOC_It: |
|
np = nn->parent; |
|
while (np->tok != MDOC_Bl) |
|
np = np->parent; |
|
switch (np->norm->Bl.type) { |
|
case LIST_column: |
|
break; |
|
case LIST_diag: |
|
case LIST_hang: |
|
case LIST_inset: |
|
case LIST_ohang: |
|
case LIST_tag: |
|
nn = nn->head; |
|
break; |
|
case LIST_bullet: |
|
case LIST_dash: |
|
case LIST_enum: |
|
case LIST_hyphen: |
|
case LIST_item: |
|
nn = nn->body->child == NULL ? n : nn->body; |
|
break; |
|
default: |
|
abort(); |
|
} |
|
break; |
|
case MDOC_Bd: |
|
case MDOC_Bl: |
|
case MDOC_D1: |
|
case MDOC_Dl: |
|
nn = nn->body->child == NULL ? n : nn->body; |
|
break; |
|
case MDOC_Pp: |
|
break; |
case MDOC_Cm: |
case MDOC_Cm: |
case MDOC_Dv: |
case MDOC_Dv: |
case MDOC_Em: |
case MDOC_Em: |
Line 1172 post_tg(POST_ARGS) |
|
Line 1206 post_tg(POST_ARGS) |
|
case MDOC_Ms: |
case MDOC_Ms: |
case MDOC_No: |
case MDOC_No: |
case MDOC_Sy: |
case MDOC_Sy: |
if (nn->child != NULL && (nn->flags & NODE_ID) == 0) |
if (nn->child == NULL) |
break; |
nn = n; |
/* FALLTHROUGH */ |
break; |
default: |
default: |
nn = n; |
nn = n; |
break; |
break; |
Line 2164 post_rs(POST_ARGS) |
|
Line 2198 post_rs(POST_ARGS) |
|
static void |
static void |
post_hyph(POST_ARGS) |
post_hyph(POST_ARGS) |
{ |
{ |
struct roff_node *nch; |
struct roff_node *n, *nch; |
char *cp; |
char *cp; |
|
|
for (nch = mdoc->last->child; nch != NULL; nch = nch->next) { |
n = mdoc->last; |
|
for (nch = n->child; nch != NULL; nch = nch->next) { |
if (nch->type != ROFFT_TEXT) |
if (nch->type != ROFFT_TEXT) |
continue; |
continue; |
cp = nch->string; |
cp = nch->string; |
Line 2176 post_hyph(POST_ARGS) |
|
Line 2211 post_hyph(POST_ARGS) |
|
while (*(++cp) != '\0') |
while (*(++cp) != '\0') |
if (*cp == '-' && |
if (*cp == '-' && |
isalpha((unsigned char)cp[-1]) && |
isalpha((unsigned char)cp[-1]) && |
isalpha((unsigned char)cp[1])) |
isalpha((unsigned char)cp[1])) { |
|
if (n->tag == NULL && n->flags & NODE_ID) |
|
n->tag = mandoc_strdup(nch->string); |
*cp = ASCII_HYPH; |
*cp = ASCII_HYPH; |
|
} |
} |
} |
} |
} |
|
|
Line 2727 post_dt(POST_ARGS) |
|
Line 2765 post_dt(POST_ARGS) |
|
mandoc_msg(MANDOCERR_MSEC_BAD, |
mandoc_msg(MANDOCERR_MSEC_BAD, |
nn->line, nn->pos, "Dt ... %s", nn->string); |
nn->line, nn->pos, "Dt ... %s", nn->string); |
mdoc->meta.vol = mandoc_strdup(nn->string); |
mdoc->meta.vol = mandoc_strdup(nn->string); |
} else |
} else { |
mdoc->meta.vol = mandoc_strdup(cp); |
mdoc->meta.vol = mandoc_strdup(cp); |
|
if (mdoc->filesec != '\0' && |
|
mdoc->filesec != *nn->string && |
|
*nn->string >= '1' && *nn->string <= '9') |
|
mandoc_msg(MANDOCERR_MSEC_FILE, nn->line, nn->pos, |
|
"*.%c vs Dt ... %c", mdoc->filesec, *nn->string); |
|
} |
|
|
/* Optional third argument: architecture. */ |
/* Optional third argument: architecture. */ |
|
|