-/* $Id: mdoc_html.c,v 1.241 2017/01/08 22:51:55 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.247 2017/01/11 17:39:53 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015, 2016, 2017 Ingo Schwarze <schwarze@openbsd.org>
static void mdoc_bk_post(MDOC_ARGS);
static int mdoc_bk_pre(MDOC_ARGS);
static int mdoc_bl_pre(MDOC_ARGS);
-static int mdoc_bt_pre(MDOC_ARGS);
-static int mdoc_bx_pre(MDOC_ARGS);
static int mdoc_cd_pre(MDOC_ARGS);
static int mdoc_d1_pre(MDOC_ARGS);
static int mdoc_dv_pre(MDOC_ARGS);
static void mdoc_quote_post(MDOC_ARGS);
static int mdoc_quote_pre(MDOC_ARGS);
static int mdoc_rs_pre(MDOC_ARGS);
-static int mdoc_rv_pre(MDOC_ARGS);
static int mdoc_sh_pre(MDOC_ARGS);
static int mdoc_skip_pre(MDOC_ARGS);
static int mdoc_sm_pre(MDOC_ARGS);
static int mdoc_ss_pre(MDOC_ARGS);
static int mdoc_sx_pre(MDOC_ARGS);
static int mdoc_sy_pre(MDOC_ARGS);
-static int mdoc_ud_pre(MDOC_ARGS);
static int mdoc_va_pre(MDOC_ARGS);
static int mdoc_vt_pre(MDOC_ARGS);
static int mdoc_xr_pre(MDOC_ARGS);
{mdoc_quote_pre, mdoc_quote_post}, /* Op */
{mdoc_ft_pre, NULL}, /* Ot */
{mdoc_pa_pre, NULL}, /* Pa */
- {mdoc_rv_pre, NULL}, /* Rv */
+ {mdoc_ex_pre, NULL}, /* Rv */
{NULL, NULL}, /* St */
{mdoc_va_pre, NULL}, /* Va */
{mdoc_vt_pre, NULL}, /* Vt */
{mdoc_quote_pre, mdoc_quote_post}, /* Bo */
{mdoc_quote_pre, mdoc_quote_post}, /* Bq */
{mdoc_xx_pre, NULL}, /* Bsx */
- {mdoc_bx_pre, NULL}, /* Bx */
+ {mdoc_xx_pre, NULL}, /* Bx */
{mdoc_skip_pre, NULL}, /* Db */
{NULL, NULL}, /* Dc */
{mdoc_quote_pre, mdoc_quote_post}, /* Do */
{NULL, NULL}, /* Oc */
{mdoc_bk_pre, mdoc_bk_post}, /* Bk */
{NULL, NULL}, /* Ek */
- {mdoc_bt_pre, NULL}, /* Bt */
+ {NULL, NULL}, /* Bt */
{NULL, NULL}, /* Hf */
{mdoc_em_pre, NULL}, /* Fr */
- {mdoc_ud_pre, NULL}, /* Ud */
+ {NULL, NULL}, /* Ud */
{mdoc_lb_pre, NULL}, /* Lb */
{mdoc_pp_pre, NULL}, /* Lp */
{mdoc_lk_pre, NULL}, /* Lk */
synopsis_pre(struct html *h, const struct roff_node *n)
{
- if (NULL == n->prev || ! (MDOC_SYNPRETTY & n->flags))
+ if (NULL == n->prev || ! (NODE_SYNPRETTY & n->flags))
return;
if (n->prev->tok == n->tok &&
int child;
struct tag *t;
+ if (n->flags & NODE_NOPRT)
+ return;
+
child = 1;
t = h->tags.head;
- n->flags &= ~MDOC_ENDED;
+ n->flags &= ~NODE_ENDED;
switch (n->type) {
case ROFFT_TEXT:
* Make sure that if we're in a literal mode already
* (i.e., within a <PRE>) don't print the newline.
*/
- if (' ' == *n->string && MDOC_LINE & n->flags)
+ if (' ' == *n->string && NODE_LINE & n->flags)
if ( ! (HTML_LITERAL & h->flags))
print_otag(h, TAG_BR, 0, NULL);
- if (MDOC_DELIMC & n->flags)
+ if (NODE_DELIMC & n->flags)
h->flags |= HTML_NOSPACE;
print_text(h, n->string);
- if (MDOC_DELIMO & n->flags)
+ if (NODE_DELIMO & n->flags)
h->flags |= HTML_NOSPACE;
return;
case ROFFT_EQN:
- if (n->flags & MDOC_LINE)
+ if (n->flags & NODE_LINE)
putchar('\n');
print_eqn(h, n->eqn);
break;
break;
}
- if (h->flags & HTML_KEEP && n->flags & MDOC_LINE) {
+ if (h->flags & HTML_KEEP && n->flags & NODE_LINE) {
h->flags &= ~HTML_KEEP;
h->flags |= HTML_PREKEEP;
}
case ROFFT_EQN:
break;
default:
- if ( ! mdocs[n->tok].post || n->flags & MDOC_ENDED)
+ if ( ! mdocs[n->tok].post || n->flags & NODE_ENDED)
break;
(*mdocs[n->tok].post)(meta, n, h);
if (n->end != ENDBODY_NOT)
- n->body->flags |= MDOC_ENDED;
+ n->body->flags |= NODE_ENDED;
if (n->end == ENDBODY_NOSPACE)
h->flags |= HTML_NOSPACE;
break;
if (!(n->child == NULL &&
(n->next == NULL ||
n->next->type == ROFFT_TEXT ||
- n->next->flags & MDOC_LINE)))
+ n->next->flags & NODE_LINE)))
h->flags |= HTML_NOSPACE;
return 1;
mdoc_ns_pre(MDOC_ARGS)
{
- if ( ! (MDOC_LINE & n->flags))
+ if ( ! (NODE_LINE & n->flags))
h->flags |= HTML_NOSPACE;
return 1;
}
static int
mdoc_xx_pre(MDOC_ARGS)
-{
- const char *pp;
- struct htmlpair tag;
- int flags;
-
- switch (n->tok) {
- case MDOC_Bsx:
- pp = "BSD/OS";
- break;
- case MDOC_Dx:
- pp = "DragonFly";
- break;
- case MDOC_Fx:
- pp = "FreeBSD";
- break;
- case MDOC_Nx:
- pp = "NetBSD";
- break;
- case MDOC_Ox:
- pp = "OpenBSD";
- break;
- case MDOC_Ux:
- pp = "UNIX";
- break;
- default:
- return 1;
- }
-
- PAIR_CLASS_INIT(&tag, "unix");
- print_otag(h, TAG_SPAN, 1, &tag);
-
- print_text(h, pp);
- if (n->child) {
- flags = h->flags;
- h->flags |= HTML_KEEP;
- print_text(h, n->child->string);
- h->flags = flags;
- }
- return 0;
-}
-
-static int
-mdoc_bx_pre(MDOC_ARGS)
{
struct htmlpair tag;
PAIR_CLASS_INIT(&tag, "unix");
print_otag(h, TAG_SPAN, 1, &tag);
-
- if (NULL != (n = n->child)) {
- print_text(h, n->string);
- h->flags |= HTML_NOSPACE;
- print_text(h, "BSD");
- } else {
- print_text(h, "BSD");
- return 0;
- }
-
- if (NULL != (n = n->next)) {
- h->flags |= HTML_NOSPACE;
- print_text(h, "-");
- h->flags |= HTML_NOSPACE;
- print_text(h, n->string);
- }
-
- return 0;
+ return 1;
}
static int
static int
mdoc_ex_pre(MDOC_ARGS)
{
- struct htmlpair tag;
- struct tag *t;
- struct roff_node *nch;
-
if (n->prev)
print_otag(h, TAG_BR, 0, NULL);
-
- PAIR_CLASS_INIT(&tag, "utility");
-
- print_text(h, "The");
-
- for (nch = n->child; nch != NULL; nch = nch->next) {
- assert(nch->type == ROFFT_TEXT);
-
- t = print_otag(h, TAG_B, 1, &tag);
- print_text(h, nch->string);
- print_tagq(h, t);
-
- if (nch->next == NULL)
- continue;
-
- if (nch->prev != NULL || nch->next->next != NULL) {
- h->flags |= HTML_NOSPACE;
- print_text(h, ",");
- }
-
- if (nch->next->next == NULL)
- print_text(h, "and");
- }
-
- if (n->child != NULL && n->child->next != NULL)
- print_text(h, "utilities exit\\~0");
- else
- print_text(h, "utility exits\\~0");
-
- print_text(h, "on success, and\\~>0 if an error occurs.");
- return 0;
+ return 1;
}
static int
break;
}
if (h->flags & HTML_NONEWLINE ||
- (nn->next && ! (nn->next->flags & MDOC_LINE)))
+ (nn->next && ! (nn->next->flags & NODE_LINE)))
continue;
else if (nn->next)
print_text(h, "\n");
const char *sp, *ep;
int sz, i, pretty;
- pretty = MDOC_SYNPRETTY & n->flags;
+ pretty = NODE_SYNPRETTY & n->flags;
synopsis_pre(h, n);
/* Split apart into type and name. */
*/
#if 0
- if (MDOC_SYNPRETTY & n->flags) {
+ if (NODE_SYNPRETTY & n->flags) {
nbuf[0] = '\0';
html_idcat(nbuf, sp, BUFSIZ);
PAIR_ID_INIT(&tag[1], nbuf);
for (n = n->child->next; n; n = n->next) {
i = 1;
- if (MDOC_SYNPRETTY & n->flags)
+ if (NODE_SYNPRETTY & n->flags)
i = 2;
t = print_otag(h, TAG_I, i, tag);
print_text(h, n->string);
* of no children.
*/
- if (MDOC_SYNPRETTY & n->flags && MDOC_LINE & n->flags)
+ if (NODE_SYNPRETTY & n->flags && NODE_LINE & n->flags)
print_text(h, "#include");
print_text(h, "<");
return 1;
}
-static int
-mdoc_rv_pre(MDOC_ARGS)
-{
- struct htmlpair tag;
- struct tag *t;
- struct roff_node *nch;
-
- if (n->prev)
- print_otag(h, TAG_BR, 0, NULL);
-
- PAIR_CLASS_INIT(&tag, "fname");
-
- if (n->child != NULL) {
- print_text(h, "The");
-
- for (nch = n->child; nch != NULL; nch = nch->next) {
- t = print_otag(h, TAG_B, 1, &tag);
- print_text(h, nch->string);
- print_tagq(h, t);
-
- h->flags |= HTML_NOSPACE;
- print_text(h, "()");
-
- if (nch->next == NULL)
- continue;
-
- if (nch->prev != NULL || nch->next->next != NULL) {
- h->flags |= HTML_NOSPACE;
- print_text(h, ",");
- }
- if (nch->next->next == NULL)
- print_text(h, "and");
- }
-
- if (n->child != NULL && n->child->next != NULL)
- print_text(h, "functions return");
- else
- print_text(h, "function returns");
-
- print_text(h, "the value\\~0 if successful;");
- } else
- print_text(h, "Upon successful completion,"
- " the value\\~0 is returned;");
-
- print_text(h, "otherwise the value\\~\\-1 is returned"
- " and the global variable");
-
- PAIR_CLASS_INIT(&tag, "var");
- t = print_otag(h, TAG_B, 1, &tag);
- print_text(h, "errno");
- print_tagq(h, t);
- print_text(h, "is set to indicate the error.");
- return 0;
-}
-
static int
mdoc_va_pre(MDOC_ARGS)
{
mdoc_pf_post(MDOC_ARGS)
{
- if ( ! (n->next == NULL || n->next->flags & MDOC_LINE))
+ if ( ! (n->next == NULL || n->next->flags & NODE_LINE))
h->flags |= HTML_NOSPACE;
}
struct htmlpair tag;
PAIR_CLASS_INIT(&tag, "none");
- print_otag(h, TAG_CODE, 1, &tag);
+ print_otag(h, TAG_SPAN, 1, &tag);
return 1;
}
return 1;
}
-static int
-mdoc_bt_pre(MDOC_ARGS)
-{
-
- print_text(h, "is currently in beta test.");
- return 0;
-}
-
-static int
-mdoc_ud_pre(MDOC_ARGS)
-{
-
- print_text(h, "currently under development.");
- return 0;
-}
-
static int
mdoc_lb_pre(MDOC_ARGS)
{
struct htmlpair tag;
- if (SEC_LIBRARY == n->sec && MDOC_LINE & n->flags && n->prev)
+ if (SEC_LIBRARY == n->sec && NODE_LINE & n->flags && n->prev)
print_otag(h, TAG_BR, 0, NULL);
PAIR_CLASS_INIT(&tag, "lib");