aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_html.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-02-01 23:10:35 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-02-01 23:10:35 +0000
commitd769b406898f4cb6b65c691825fb2a8f9d89aa13 (patch)
treeb5fa70221be2cd8a20f1980059486fe0246abb5a /mdoc_html.c
parent551e90b6e3a351a26caa834d997cc49edfe32535 (diff)
downloadmandoc-d769b406898f4cb6b65c691825fb2a8f9d89aa13.tar.gz
mandoc-d769b406898f4cb6b65c691825fb2a8f9d89aa13.tar.zst
mandoc-d769b406898f4cb6b65c691825fb2a8f9d89aa13.zip
fix .Eo/.Ec spacing
Diffstat (limited to 'mdoc_html.c')
-rw-r--r--mdoc_html.c66
1 files changed, 52 insertions, 14 deletions
diff --git a/mdoc_html.c b/mdoc_html.c
index 337e5dba..bc89a4af 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.220 2015/01/30 22:04:44 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.221 2015/02/01 23:10:35 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -81,6 +81,8 @@ static int mdoc_fl_pre(MDOC_ARGS);
static int mdoc_fn_pre(MDOC_ARGS);
static int mdoc_ft_pre(MDOC_ARGS);
static int mdoc_em_pre(MDOC_ARGS);
+static void mdoc_eo_post(MDOC_ARGS);
+static int mdoc_eo_pre(MDOC_ARGS);
static int mdoc_er_pre(MDOC_ARGS);
static int mdoc_ev_pre(MDOC_ARGS);
static int mdoc_ex_pre(MDOC_ARGS);
@@ -189,7 +191,7 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = {
{NULL, NULL}, /* Ec */ /* FIXME: no space */
{NULL, NULL}, /* Ef */
{mdoc_em_pre, NULL}, /* Em */
- {mdoc_quote_pre, mdoc_quote_post}, /* Eo */
+ {mdoc_eo_pre, mdoc_eo_post}, /* Eo */
{mdoc_xx_pre, NULL}, /* Fx */
{mdoc_ms_pre, NULL}, /* Ms */
{mdoc_no_pre, NULL}, /* No */
@@ -2112,8 +2114,6 @@ mdoc_quote_pre(MDOC_ARGS)
return(1);
print_text(h, n->norm->Es->child->string);
break;
- case MDOC_Eo:
- break;
case MDOC_Do:
/* FALLTHROUGH */
case MDOC_Dq:
@@ -2155,9 +2155,7 @@ mdoc_quote_post(MDOC_ARGS)
if (n->type != MDOC_BODY && n->type != MDOC_ELEM)
return;
- if ( ! (n->tok == MDOC_En ||
- (n->tok == MDOC_Eo && n->end == ENDBODY_SPACE)))
- h->flags |= HTML_NOSPACE;
+ h->flags |= HTML_NOSPACE;
switch (n->tok) {
case MDOC_Ao:
@@ -2181,14 +2179,12 @@ mdoc_quote_post(MDOC_ARGS)
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;
+ if (n->norm->Es == NULL ||
+ n->norm->Es->child == NULL ||
+ n->norm->Es->child->next == NULL)
+ h->flags &= ~HTML_NOSPACE;
+ else
print_text(h, n->norm->Es->child->next->string);
- }
- break;
- case MDOC_Eo:
break;
case MDOC_Qo:
/* FALLTHROUGH */
@@ -2216,3 +2212,45 @@ mdoc_quote_post(MDOC_ARGS)
/* NOTREACHED */
}
}
+
+static int
+mdoc_eo_pre(MDOC_ARGS)
+{
+
+ if (n->type != MDOC_BODY)
+ return(1);
+
+ if (n->end == ENDBODY_NOT &&
+ n->parent->head->child == NULL &&
+ n->child != NULL &&
+ n->child->end != ENDBODY_NOT)
+ print_text(h, "\\&");
+ else if (n->end != ENDBODY_NOT ? n->child != NULL :
+ n->parent->head->child != NULL &&
+ (n->parent->body->child != NULL ||
+ n->parent->tail->child != NULL))
+ h->flags |= HTML_NOSPACE;
+ return(1);
+}
+
+static void
+mdoc_eo_post(MDOC_ARGS)
+{
+ int body, tail;
+
+ if (n->type != MDOC_BODY)
+ return;
+
+ if (n->end != ENDBODY_NOT) {
+ h->flags &= ~HTML_NOSPACE;
+ return;
+ }
+
+ body = n->child != NULL || n->parent->head->child != NULL;
+ tail = n->parent->tail != NULL && n->parent->tail->child != NULL;
+
+ if (body && tail)
+ h->flags |= HTML_NOSPACE;
+ else if ( ! tail)
+ h->flags &= ~HTML_NOSPACE;
+}