]> git.cameronkatri.com Git - mandoc.git/blobdiff - mdoc_term.c
Make SYNOPSIS sections and code having .nr nS enabled
[mandoc.git] / mdoc_term.c
index d039af4c146ddce785ee708fc960ac2f4405cb2b..98b4fa70e8e9f636a2356f23f1f6d72357fa5ee3 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: mdoc_term.c,v 1.192 2010/10/01 21:51:13 schwarze Exp $ */
+/*     $Id: mdoc_term.c,v 1.197 2010/12/11 14:40:51 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -319,9 +319,12 @@ print_mdoc_node(DECL_ARGS)
        /*
         * Keeps only work until the end of a line.  If a keep was
         * invoked in a prior line, revert it to PREKEEP.
+        *
+        * Also let SYNPRETTY sections behave as if they were wrapped
+        * in a `Bk' block.
         */
 
-       if (TERMP_KEEP & p->flags) {
+       if (TERMP_KEEP & p->flags || MDOC_SYNPRETTY & n->flags) {
                if (n->prev && n->prev->line != n->line) {
                        p->flags &= ~TERMP_KEEP;
                        p->flags |= TERMP_PREKEEP;
@@ -333,6 +336,16 @@ print_mdoc_node(DECL_ARGS)
                }
        }
 
+       /*
+        * Since SYNPRETTY sections aren't "turned off" with `Ek',
+        * we have to intuit whether we should disable formatting.
+        */
+
+       if ( ! (MDOC_SYNPRETTY & n->flags) &&
+           ((n->prev   && MDOC_SYNPRETTY & n->prev->flags) ||
+            (n->parent && MDOC_SYNPRETTY & n->parent->flags)))
+               p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
+
        if (chld && n->child)
                print_mdoc_nodelist(p, &npair, m, n->child);
 
@@ -1584,12 +1597,18 @@ termp_bd_pre(DECL_ARGS)
                 * anyway, so don't sweat it.
                 */
                switch (nn->tok) {
+               case (MDOC_Sm):
+                       /* FALLTHROUGH */
                case (MDOC_br):
                        /* FALLTHROUGH */
                case (MDOC_sp):
                        /* FALLTHROUGH */
                case (MDOC_Bl):
                        /* FALLTHROUGH */
+               case (MDOC_D1):
+                       /* FALLTHROUGH */
+               case (MDOC_Dl):
+                       /* FALLTHROUGH */
                case (MDOC_Lp):
                        /* FALLTHROUGH */
                case (MDOC_Pp):
@@ -1655,7 +1674,7 @@ termp_xx_pre(DECL_ARGS)
        pp = NULL;
        switch (n->tok) {
        case (MDOC_Bsx):
-               pp = "BSDI BSD/OS";
+               pp = "BSD/OS";
                break;
        case (MDOC_Dx):
                pp = "DragonFly";
@@ -2074,7 +2093,7 @@ termp_lk_pre(DECL_ARGS)
 
        nn = sv = n->child;
 
-       if (NULL == nn->next)
+       if (NULL == nn || NULL == nn->next)
                return(1);
 
        for (nn = nn->next; nn; nn = nn->next)