+
+static int
+mdoc_bk_pre(MDOC_ARGS)
+{
+
+ switch (n->type) {
+ case MDOC_BLOCK:
+ break;
+ case MDOC_HEAD:
+ return(0);
+ case MDOC_BODY:
+ if (n->parent->args || 0 == n->prev->nchild)
+ h->flags |= HTML_PREKEEP;
+ break;
+ default:
+ abort();
+ /* NOTREACHED */
+ }
+
+ return(1);
+}
+
+static void
+mdoc_bk_post(MDOC_ARGS)
+{
+
+ if (MDOC_BODY == n->type)
+ h->flags &= ~(HTML_KEEP | HTML_PREKEEP);
+}
+
+static int
+mdoc_quote_pre(MDOC_ARGS)
+{
+ struct htmlpair tag;
+
+ if (MDOC_BODY != n->type)
+ return(1);
+
+ switch (n->tok) {
+ case MDOC_Ao:
+ /* FALLTHROUGH */
+ case MDOC_Aq:
+ print_text(h, "\\(la");
+ break;
+ case MDOC_Bro:
+ /* FALLTHROUGH */
+ case MDOC_Brq:
+ print_text(h, "\\(lC");
+ break;
+ case MDOC_Bo:
+ /* FALLTHROUGH */
+ case MDOC_Bq:
+ print_text(h, "\\(lB");
+ break;
+ case MDOC_Oo:
+ /* FALLTHROUGH */
+ case MDOC_Op:
+ print_text(h, "\\(lB");
+ h->flags |= HTML_NOSPACE;
+ PAIR_CLASS_INIT(&tag, "opt");
+ print_otag(h, TAG_SPAN, 1, &tag);
+ break;
+ case MDOC_En:
+ if (NULL == n->norm->Es ||
+ NULL == n->norm->Es->child)
+ return(1);
+ print_text(h, n->norm->Es->child->string);
+ break;
+ case MDOC_Eo:
+ break;
+ case MDOC_Do:
+ /* FALLTHROUGH */
+ case MDOC_Dq:
+ /* FALLTHROUGH */
+ case MDOC_Qo:
+ /* FALLTHROUGH */
+ case MDOC_Qq:
+ print_text(h, "\\(lq");
+ break;
+ case MDOC_Po:
+ /* FALLTHROUGH */
+ case MDOC_Pq:
+ print_text(h, "(");
+ break;
+ case MDOC_Ql:
+ print_text(h, "\\(oq");
+ h->flags |= HTML_NOSPACE;
+ PAIR_CLASS_INIT(&tag, "lit");
+ print_otag(h, TAG_CODE, 1, &tag);
+ break;
+ case MDOC_So:
+ /* FALLTHROUGH */
+ case MDOC_Sq:
+ print_text(h, "\\(oq");
+ break;
+ default:
+ abort();
+ /* NOTREACHED */
+ }
+
+ h->flags |= HTML_NOSPACE;
+ return(1);
+}
+
+static void
+mdoc_quote_post(MDOC_ARGS)
+{
+
+ if (MDOC_BODY != n->type)
+ return;
+
+ if (MDOC_En != n->tok)
+ h->flags |= HTML_NOSPACE;
+
+ switch (n->tok) {
+ case MDOC_Ao:
+ /* FALLTHROUGH */
+ case MDOC_Aq:
+ print_text(h, "\\(ra");
+ break;
+ case MDOC_Bro:
+ /* FALLTHROUGH */
+ case MDOC_Brq:
+ print_text(h, "\\(rC");
+ break;
+ case MDOC_Oo:
+ /* FALLTHROUGH */
+ case MDOC_Op:
+ /* FALLTHROUGH */
+ case MDOC_Bo:
+ /* FALLTHROUGH */
+ case MDOC_Bq:
+ print_text(h, "\\(rB");
+ break;
+ case MDOC_En:
+ if (NULL != n->norm->Es &&
+ NULL != n->norm->Es->child &&
+ NULL != n->norm->Es->child->next) {
+ h->flags |= HTML_NOSPACE;
+ print_text(h, n->norm->Es->child->next->string);
+ }
+ break;
+ case MDOC_Eo:
+ break;
+ case MDOC_Qo:
+ /* FALLTHROUGH */
+ case MDOC_Qq:
+ /* FALLTHROUGH */
+ case MDOC_Do:
+ /* FALLTHROUGH */
+ case MDOC_Dq:
+ print_text(h, "\\(rq");
+ break;
+ case MDOC_Po:
+ /* FALLTHROUGH */
+ case MDOC_Pq:
+ print_text(h, ")");
+ break;
+ case MDOC_Ql:
+ /* FALLTHROUGH */
+ case MDOC_So:
+ /* FALLTHROUGH */
+ case MDOC_Sq:
+ print_text(h, "\\(cq");
+ break;
+ default:
+ abort();
+ /* NOTREACHED */
+ }
+}