Simplify treatment of the copyright notice, now I've also simplified
[sgt/halibut] / bk_text.c
index 48e99f4..15a4fc0 100644 (file)
--- a/bk_text.c
+++ b/bk_text.c
@@ -182,6 +182,7 @@ void text_backend(paragraph *sourceform, keywordlist *keywords,
     word spaceword;
     FILE *fp;
     char *prefixextra;
+    int nesting, nestindent;
     int indentb, indenta;
 
     IGNORE(keywords);                 /* we don't happen to need this */
@@ -207,21 +208,28 @@ void text_backend(paragraph *sourceform, keywordlist *keywords,
            text_heading(fp, NULL, NULL, p->words,
                         conf.atitle, conf.indent, conf.width);
 
-    /* Do the preamble and copyright */
-    for (p = sourceform; p; p = p->next)
-       if (p->type == para_Preamble)
-           text_para(fp, NULL, NULL, p->words,
-                     conf.indent_preambles ? conf.indent : 0, 0,
-                     conf.width + (conf.indent_preambles ? 0 : conf.indent));
-    for (p = sourceform; p; p = p->next)
-       if (p->type == para_Copyright)
-           text_para(fp, NULL, NULL, p->words,
-                     conf.indent_preambles ? conf.indent : 0, 0,
-                     conf.width + (conf.indent_preambles ? 0 : conf.indent));
+    nestindent = conf.listindentbefore + conf.listindentafter;
+    nesting = (conf.indent_preambles ? 0 : -conf.indent);
 
     /* Do the main document */
     for (p = sourceform; p; p = p->next) switch (p->type) {
 
+      case para_QuotePush:
+       nesting += 2;
+       break;
+      case para_QuotePop:
+       nesting -= 2;
+       assert(nesting >= 0);
+       break;
+
+      case para_LcontPush:
+       nesting += nestindent;
+       break;
+      case para_LcontPop:
+       nesting -= nestindent;
+       assert(nesting >= 0);
+       break;
+
        /*
         * Things we ignore because we've already processed them or
         * aren't going to touch them in this pass.
@@ -230,8 +238,6 @@ void text_backend(paragraph *sourceform, keywordlist *keywords,
       case para_BR:
       case para_Biblio:                       /* only touch BiblioCited */
       case para_VersionID:
-      case para_Copyright:
-      case para_Preamble:
       case para_NoCite:
       case para_Title:
        break;
@@ -244,6 +250,7 @@ void text_backend(paragraph *sourceform, keywordlist *keywords,
       case para_UnnumberedChapter:
        text_heading(fp, p->kwtext, p->kwtext2, p->words,
                     conf.achapter, conf.indent, conf.width);
+       nesting = 0;
        break;
 
       case para_Heading:
@@ -254,10 +261,13 @@ void text_backend(paragraph *sourceform, keywordlist *keywords,
        break;
 
       case para_Rule:
-       text_rule(fp, conf.indent, conf.width);
+       text_rule(fp, conf.indent + nesting, conf.width - nesting);
        break;
 
       case para_Normal:
+      case para_Copyright:
+      case para_DescribedThing:
+      case para_Description:
       case para_BiblioCited:
       case para_Bullet:
       case para_NumberedList:
@@ -271,6 +281,11 @@ void text_backend(paragraph *sourceform, keywordlist *keywords,
            prefixextra = ".";         /* FIXME: configurability */
            indentb = conf.listindentbefore;
            indenta = conf.listindentafter;
+       } else if (p->type == para_Description) {
+           prefix = NULL;
+           prefixextra = NULL;
+           indentb = conf.listindentbefore;
+           indenta = conf.listindentafter;
        } else {
            prefix = NULL;
            prefixextra = NULL;
@@ -289,8 +304,8 @@ void text_backend(paragraph *sourceform, keywordlist *keywords,
            body = p->words;
        }
        text_para(fp, prefix, prefixextra, body,
-                 conf.indent + indentb, indenta,
-                 conf.width - indentb - indenta);
+                 conf.indent + nesting + indentb, indenta,
+                 conf.width - nesting - indentb - indenta);
        if (wp) {
            wp->next = NULL;
            free_word_list(body);
@@ -298,7 +313,9 @@ void text_backend(paragraph *sourceform, keywordlist *keywords,
        break;
 
       case para_Code:
-       text_codepara(fp, p->words, conf.indent + conf.indent_code, conf.width - 2 * conf.indent_code);
+       text_codepara(fp, p->words,
+                     conf.indent + nesting + conf.indent_code,
+                     conf.width - nesting - 2 * conf.indent_code);
        break;
     }