[liblouis-liblouisxml] [liblouisutdml] push by john.bo...@xxxxxxxxxxxxxxxxx - enhancements inspired by Bible transcription challenge on 2012-02-21 14:00 GMT

  • From: liblouisutdml@xxxxxxxxxxxxxx
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Tue, 21 Feb 2012 14:01:18 +0000

Revision: 56e1541c2bf5
Author:   John Boyer <john.boyer@xxxxxxxxxxxxxxxxx>
Date:     Tue Feb 21 05:59:37 2012
Log:      enhancements inspired by Bible transcription challenge
http://code.google.com/p/liblouisutdml/source/detail?r=56e1541c2bf5

Modified:
 /lbu_files/preferences.cfg
 /liblouisutdml/louisutdml.h
 /liblouisutdml/readconfig.c
 /liblouisutdml/sem_enum.h
 /liblouisutdml/sem_names.h
 /liblouisutdml/transcribe_paragraph.c
 /liblouisutdml/transcriber.c

=======================================
--- /lbu_files/preferences.cfg  Fri Feb 10 13:15:22 2012
+++ /lbu_files/preferences.cfg  Tue Feb 21 05:59:37 2012
@@ -14,6 +14,7 @@
        pageSeparatorNumber yes
        numberBraillePages yes
        backFormat html
+       backLineLength 70
        hyphenate no
        formatFor textDevice
        lineEnd \r\n
@@ -24,10 +25,9 @@
        printPageNumberAt top
        braillePageNumberAt bottom
        outputEncoding utf8
-       backLineLength 70
-       topMargin 0.5
        contents no
        lineFill '
+       topMargin 0.5
        leftMargin 1
        rightMargin 0.5
        bottomMargin 0.5
@@ -64,7 +64,7 @@
        pefSem utd.sem

 #(miscellaneous)
-       #include
+       #include (another configuration file)
        #mode (built-in defaults)
        inputTextEncoding ascii8
        debug no
@@ -77,7 +77,7 @@
        linesAfter 0
        leftMargin 0
        firstLineIndent 0
-       translate contracted
+       #translationTable (a table name)
        skipNumberLines no
        format leftJustified
        newPageBefore no
@@ -88,6 +88,7 @@
        keepWithNext no
        dontSplit no
        orphanControl 0
+       newlineAfter yes

 style arith
 style attribution
=======================================
--- /liblouisutdml/louisutdml.h Fri Feb 17 07:19:45 2012
+++ /liblouisutdml/louisutdml.h Tue Feb 21 05:59:37 2012
@@ -76,13 +76,14 @@
   int dont_split;
   int orphan_control;
   int first_line_indent;       /* At true margin if negative */
-  sem_act translate;
+  char *translation_table;
   int skip_number_lines;       /*Don't write on lines with page numbers */
   StyleFormat format;
   BrlPageNumFormat brlNumFormat;
   int newpage_before;
   int newpage_after;
   int righthand_page;
+  int newline_after;
 } StyleType;

 #ifdef _WIN32
=======================================
--- /liblouisutdml/readconfig.c Sat Feb 18 07:01:09 2012
+++ /liblouisutdml/readconfig.c Tue Feb 21 05:59:37 2012
@@ -1007,7 +1007,7 @@
              "2",
              "firstLineIndent",
              "3",
-             "translate",
+             "translattionTable",
              "6",
              "skipNumberLines",
              "7",
@@ -1029,6 +1029,8 @@
              "15",
              "orphanControl",
              "16",
+             "newlineAfter",
+             "17",
              NULL
            };
            static const char *formats[] = {
@@ -1045,10 +1047,23 @@
              "listColumns",
              "5",
              "listLines",
-             "6", "computerCoded", "7", "contents", "8", NULL
+             "6",
+             "computerCoded",
+             "7",
+             "contents",
+             "8",
+             NULL
            };
            static const char *pageNumFormats[] = {
-             "normal", "0", "blank", "1", "p", "2", "roman", "3", NULL
+             "normal",
+             "0",
+             "blank",
+             "1",
+             "p",
+             "2",
+             "roman",
+             "3",
+             NULL
            };
            StyleType *style;
            sem_act styleAction;
@@ -1061,6 +1076,7 @@
            styleAction = find_semantic_number (nested->value);
            style = new_style (nested->value);
            style->action = styleAction;
+           style->newline_after = 1;
            while (parseLine (nested))
              {
                checkSubActions (nested, mainActions, actions);
@@ -1083,17 +1099,7 @@
                    style->first_line_indent = atoi (nested->value);
                    break;
                  case 6:
-                   switch ((k = find_semantic_number (nested->value)))
-                     {
-                     case contracted:
-                     case uncontracted:
-                     case compbrl:
-                       style->translate = k;
-                       break;
-                     default:
-                       configureError (nested, "no such translation");
-                       break;
-                     }
+                   style->translation_table = findTable (nested);
                    break;
                  case 7:
                    if ((k = checkValues (nested, yesNo)) != NOTFOUND)
@@ -1134,6 +1140,10 @@
                  case 16:
                    style->orphan_control = atoi (nested->value);
                    break;
+                 case 17:
+                   if ((k = checkValues (nested, yesNo)) != NOTFOUND)
+                     style->newline_after = k;
+                 break;
                  default:
                    configureError (nested, "Program error in readconfig.c");
                    continue;
=======================================
--- /liblouisutdml/sem_enum.h   Tue Apr  5 17:35:03 2011
+++ /liblouisutdml/sem_enum.h   Tue Feb 21 05:59:37 2012
@@ -75,6 +75,8 @@
   contracted,
   /* General text */
   pagenum,
+  pagebreak,
+  attrtotext,
   runninghead,
   footer,
   boxline,
=======================================
--- /liblouisutdml/sem_names.h  Tue Apr  5 17:35:03 2011
+++ /liblouisutdml/sem_names.h  Tue Feb 21 05:59:37 2012
@@ -40,6 +40,8 @@
   "uncontracted",
   "contracted",
   "pagenum",
+  "pagebreak",
+  "attrtotext",
   "runninghead",
   "footer",
   "boxline",
=======================================
--- /liblouisutdml/transcribe_paragraph.c       Wed Feb  8 03:49:55 2012
+++ /liblouisutdml/transcribe_paragraph.c       Tue Feb 21 05:59:37 2012
@@ -185,12 +185,12 @@
       break;
     case configtweak:
       do_configstring (node);
-    ud->main_braille_table = ud->contracted_table_name;
-  if (!lou_getTable (ud->main_braille_table))
-    {
-      lou_logPrint ("Cannot open main table %s", ud->main_braille_table);
-      kill_safely ();
-    }
+      ud->main_braille_table = ud->contracted_table_name;
+      if (!lou_getTable (ud->main_braille_table))
+       {
+         lou_logPrint ("Cannot open main table %s", ud->main_braille_table);
+         kill_safely ();
+       }
       break;
     case htmllink:
       if (ud->format_for != browser)
@@ -279,58 +279,58 @@
        {
        case XML_ELEMENT_NODE:
          if (ud->format_for == utd)
-         {
-         }
+           {
+           }
          else
-         {
-         style_this = is_style (child);
-         if (style_this && ud->braille_pages)
-           {
-             if (keep_with_next_this && ud->lines_length > 0)
-               keep_with_previous_this = 1;
-             keep_with_next_this = 0;
-             if (!dont_split)
-               {
-                 if (ud->lines_on_page > 0 &&
-                     !((keep_with_previous || keep_with_previous_this) &&
-                       !ud->outbuf3_enabled))
-                   {
-                     if (style_this->dont_split
-                         || style_this->keep_with_next)
-                       dont_split_this = 1;
-                     else if (style_this->orphan_control > 1)
-                       orphan_control_this = style_this->orphan_control;
-                   }
-                 keep_with_next_this = style_this->keep_with_next;
-               }
-             if (dont_split_this || orphan_control_this)
-               {
-                 if (!ud->outbuf3_enabled)
-                   {
-             saved_child = child;
-                     saved_branchCount = branchCount - 1;
-                     saveState ();
-                     state_saved = 1;
-                     ud->outbuf3_enabled = 1;
-                     ud->lines_length = 0;
+           {
+             style_this = is_style (child);
+             if (style_this && ud->braille_pages)
+               {
+                 if (keep_with_next_this && ud->lines_length > 0)
+                   keep_with_previous_this = 1;
+                 keep_with_next_this = 0;
+                 if (!dont_split)
+                   {
+                     if (ud->lines_on_page > 0 &&
+                         !((keep_with_previous || keep_with_previous_this) &&
+                           !ud->outbuf3_enabled))
+                       {
+                         if (style_this->dont_split
+                             || style_this->keep_with_next)
+                           dont_split_this = 1;
+                         else if (style_this->orphan_control > 1)
+                           orphan_control_this = style_this->orphan_control;
+                       }
+                     keep_with_next_this = style_this->keep_with_next;
+                   }
+                 if (dont_split_this || orphan_control_this)
+                   {
+                     if (!ud->outbuf3_enabled)
+                       {
+                         saved_child = child;
+                         saved_branchCount = branchCount - 1;
+                         saveState ();
+                         state_saved = 1;
+                         ud->outbuf3_enabled = 1;
+                         ud->lines_length = 0;
+                       }
+                   }
+                 if (dont_split_this)
+                   dont_split = dont_split_this;
+                 if (keep_with_next_this)
+                   keep_with_next = keep_with_next_this;
+                 if (keep_with_previous_this)
+                   {
+                     keep_with_previous = keep_with_previous_this;
+                     keep_with_previous_pos = ud->lines_length;
+                   }
+                 if (orphan_control_this)
+                   {
+                     orphan_control = orphan_control_this;
+                     orphan_control_pos = ud->lines_length;
                    }
                }
-             if (dont_split_this)
-               dont_split = dont_split_this;
-             if (keep_with_next_this)
-               keep_with_next = keep_with_next_this;
-             if (keep_with_previous_this)
-               {
-                 keep_with_previous = keep_with_previous_this;
-                 keep_with_previous_pos = ud->lines_length;
-               }
-             if (orphan_control_this)
-               {
-                 orphan_control = orphan_control_this;
-                 orphan_control_pos = ud->lines_length;
-               }
-           }
-         }
+           }
          if (strcmp (child->name, "brl") != 0)
            transcribe_paragraph (child, 1);
          break;
@@ -349,120 +349,122 @@
       if (child != NULL)
        child = child->next;
       if (ud->format_for == utd)
-      {
-      }
+       {
+       }
       else
-      {
-      if (ud->outbuf3_enabled)
-       {
-         if (dont_split_status >= 0 &&
-             keep_with_previous_status >= 0 && orphan_control_status >= 0)
-           {
-             if (keep_with_previous)
-               {
-                 if (keep_with_previous_this)
-                   keep_with_previous_status = 1;
-                 else if (keep_with_previous_pos < ud->lines_length)
-                   keep_with_previous_status = 1;
-                 else
-                   keep_with_previous_status = 0;
-                 if (keep_with_previous_pos < ud->lines_length &&
-                     ud->lines_pagenum[keep_with_previous_pos] >
-                     ud->lines_pagenum[keep_with_previous_pos - 1] &&
-                     !ud->lines_newpage[keep_with_previous_pos])
-                   keep_with_previous_status = -1;
-               }
-             if (dont_split_this)
-               {
-                 dont_split_status = 1;
-                 for (i = 1; i < ud->lines_length; i++)
-                   {
-                     if (ud->lines_pagenum[i] > ud->lines_pagenum[i - 1])
-                       {
-                         if (!ud->lines_newpage[i])
-                           dont_split_status = -1;
-                         break;
+       {
+         if (ud->outbuf3_enabled)
+           {
+             if (dont_split_status >= 0 &&
+                 keep_with_previous_status >= 0
+                 && orphan_control_status >= 0)
+               {
+                 if (keep_with_previous)
+                   {
+                     if (keep_with_previous_this)
+                       keep_with_previous_status = 1;
+                     else if (keep_with_previous_pos < ud->lines_length)
+                       keep_with_previous_status = 1;
+                     else
+                       keep_with_previous_status = 0;
+                     if (keep_with_previous_pos < ud->lines_length &&
+                         ud->lines_pagenum[keep_with_previous_pos] >
+                         ud->lines_pagenum[keep_with_previous_pos - 1] &&
+                         !ud->lines_newpage[keep_with_previous_pos])
+                       keep_with_previous_status = -1;
+                   }
+                 if (dont_split_this)
+                   {
+                     dont_split_status = 1;
+                     for (i = 1; i < ud->lines_length; i++)
+                       {
+                         if (ud->lines_pagenum[i] > ud->lines_pagenum[i - 1])
+                           {
+                             if (!ud->lines_newpage[i])
+                               dont_split_status = -1;
+                             break;
+                           }
                        }
                    }
-               }
-             if (orphan_control)
-               {
-                 if (orphan_control_this)
-                   orphan_control_status = 1;
-                 else
-                   orphan_control_status = 0;
-                 i = 1;
-                 while (i < orphan_control
-                        && orphan_control_pos + i < ud->lines_length)
-                   {
-                     if (ud->lines_pagenum[orphan_control_pos + i] >
-                         ud->lines_pagenum[orphan_control_pos + i - 1])
-                       {
-                         if (!ud->lines_newpage[i])
-                           orphan_control_status = -1;
-                         break;
-                       }
-                     i++;
-                   }
-                 if (i == orphan_control)
-                   orphan_control_status = 1;
-               }
-           }
-         if (dont_split_status < 0 ||
-             keep_with_previous_status < 0 || orphan_control_status < 0)
-           {
-             if (state_saved)
+                 if (orphan_control)
+                   {
+                     if (orphan_control_this)
+                       orphan_control_status = 1;
+                     else
+                       orphan_control_status = 0;
+                     i = 1;
+                     while (i < orphan_control
+                            && orphan_control_pos + i < ud->lines_length)
+                       {
+                         if (ud->lines_pagenum[orphan_control_pos + i] >
+                             ud->lines_pagenum[orphan_control_pos + i - 1])
+                           {
+                             if (!ud->lines_newpage[i])
+                               orphan_control_status = -1;
+                             break;
+                           }
+                         i++;
+                       }
+                     if (i == orphan_control)
+                       orphan_control_status = 1;
+                   }
+               }
+             if (dont_split_status < 0 ||
+                 keep_with_previous_status < 0 || orphan_control_status < 0)
+               {
+                 if (state_saved)
+                   {
+                     dont_split = 0;
+                     dont_split_status = 0;
+                     keep_with_next = 0;
+                     keep_with_previous = 0;
+                     keep_with_previous_status = 0;
+                     orphan_control = 0;
+                     orphan_control_status = 0;
+                     restoreState ();
+                     child = saved_child;
+                     branchCount = saved_branchCount;
+                     state_saved = 0;
+                     ud->outbuf3_len_so_far = 0;
+                     ud->outbuf3_enabled = 0;
+                     do_newpage ();
+                   }
+                 else
+                   break;
+               }
+             if (dont_split_status > 0)
                {
                  dont_split = 0;
                  dont_split_status = 0;
-                 keep_with_next = 0;
+               }
+             if (keep_with_previous_status > 0)
+               {
                  keep_with_previous = 0;
                  keep_with_previous_status = 0;
+               }
+             if (orphan_control_status > 0)
+               {
                  orphan_control = 0;
                  orphan_control_status = 0;
-                 restoreState ();
-                 child = saved_child;
-                 branchCount = saved_branchCount;
-                 state_saved = 0;
-                 ud->outbuf3_len_so_far = 0;
+               }
+             if ((!dont_split && !keep_with_previous &&
+                  !keep_with_next && !orphan_control) || (!child
+                                                          && state_saved))
+               {
+                 write_buffer (3, 0);
                  ud->outbuf3_enabled = 0;
-                 do_newpage ();
-               }
-             else
-               break;
-           }
-         if (dont_split_status > 0)
-           {
-             dont_split = 0;
-             dont_split_status = 0;
-           }
-         if (keep_with_previous_status > 0)
-           {
-             keep_with_previous = 0;
-             keep_with_previous_status = 0;
-           }
-         if (orphan_control_status > 0)
-           {
-             orphan_control = 0;
-             orphan_control_status = 0;
-           }
-         if ((!dont_split && !keep_with_previous &&
-              !keep_with_next && !orphan_control) || (!child && state_saved))
-           {
-             write_buffer (3, 0);
-             ud->outbuf3_enabled = 0;
-             state_saved = 0;
-           }
-       }
-      if (dont_split_this)
-       dont_split = 0;
-      if (keep_with_next_this)
-       keep_with_next = 0;
-      if (keep_with_previous_this)
-       keep_with_previous = 0;
-      if (orphan_control_this)
-       orphan_control = 0;
-    }
+                 state_saved = 0;
+               }
+           }
+         if (dont_split_this)
+           dont_split = 0;
+         if (keep_with_next_this)
+           keep_with_next = 0;
+         if (keep_with_previous_this)
+           keep_with_previous = 0;
+         if (orphan_control_this)
+           orphan_control = 0;
+       }
     }
   insert_code (node, branchCount);
   insert_code (node, -1);
@@ -472,22 +474,40 @@
     switch (ud->stack[ud->top])
       {
       case runninghead:
-       insert_translation (ud->main_braille_table);
-       if (ud->translated_length > (ud->cells_per_line - 9))
-         ud->running_head_length = ud->cells_per_line - 9;
+       if (ud->format_for == utd)
+         {
+           memcpy (ud->running_head, ud->text_buffer, ud->text_length *
+                   CHARSIZE);
+           ud->running_head_length = ud->text_length;
+         }
        else
-         ud->running_head_length = ud->translated_length;
-       memcpy (&ud->running_head[0], &ud->translated_buffer[0],
-               ud->running_head_length * CHARSIZE);
+         {
+           insert_translation (ud->main_braille_table);
+           if (ud->translated_length > (ud->cells_per_line - 9))
+             ud->running_head_length = ud->cells_per_line - 9;
+           else
+             ud->running_head_length = ud->translated_length;
+           memcpy (&ud->running_head[0], &ud->translated_buffer[0],
+                   ud->running_head_length * CHARSIZE);
+         }
        break;
       case footer:
-       insert_translation (ud->main_braille_table);
-       if (ud->translated_length > (ud->cells_per_line - 9))
-         ud->footer_length = ud->cells_per_line - 9;
+       if (ud->format_for == utd)
+         {
+           memcpy (ud->footer, ud->text_buffer, ud->text_length *
+           CHARSIZE);
+           ud->footer_length = ud->text_length;
+         }
        else
-         ud->footer_length = ud->translated_length;
-       memcpy (&ud->footer[0], &ud->translated_buffer[0],
-               ud->footer_length * CHARSIZE);
+         {
+           insert_translation (ud->main_braille_table);
+           if (ud->translated_length > (ud->cells_per_line - 9))
+             ud->footer_length = ud->cells_per_line - 9;
+           else
+             ud->footer_length = ud->translated_length;
+           memcpy (&ud->footer[0], &ud->translated_buffer[0],
+                   ud->footer_length * CHARSIZE);
+         }
        break;
       default:
        break;
=======================================
--- /liblouisutdml/transcriber.c        Fri Feb 17 07:19:45 2012
+++ /liblouisutdml/transcriber.c        Tue Feb 21 05:59:37 2012
@@ -638,6 +638,8 @@
   int translationLength;
   int translatedLength;
   int k;
+  if (style->translation_table != NULL)
+    table = style->translation_table;
   if (table == NULL)
     {
       memset (ud->typeform, 0, sizeof (ud->typeform));
@@ -795,6 +797,7 @@

 static int startLine ();
 static int finishLine ();
+static int lastLineInStyle;

 static int
 makeBlankLines (int number)
@@ -1389,9 +1392,6 @@
     }
   return availableCells;
 }
-
-static int shortBrlOnly (int numSpaces, const widechar * content, int
-                        length, int kind);

 static int
 centerHeadFoot (widechar * toCenter, int length)
@@ -1403,16 +1403,6 @@
     length = numCells - 4;
   leadingBlanks = (numCells - length) / 2;
   trailingBlanks = numCells - leadingBlanks - length;
-  if (ud->format_for == utd)
-    {
-      if (!shortBrlOnly (leadingBlanks, toCenter, length, 1))
-       return 0;
-      if (!shortBrlOnly (trailingBlanks, pageNumberString,
-                        pageNumberLength, 1))
-       return 0;
-    }
-  else
-    {
       if (!insertCharacters (blanks, leadingBlanks))
        return 0;
       if (!insertWidechars (toCenter, length))
@@ -1421,7 +1411,6 @@
        return 0;
       if (!insertWidechars (pageNumberString, pageNumberLength))
        return 0;
-    }
   return 1;
 }

@@ -1480,9 +1469,11 @@
                }
            }
        }
-
+      //if (lastLineInStyle && !style->newline_after)
+      {
       if (!insertCharacters (ud->lineEnd, strlen (ud->lineEnd)))
        return 0;
+       }
       if (ud->braille_pages && ud->lines_on_page == ud->lines_per_page)
        {
          if (!nextBraillePage ())
@@ -2149,7 +2140,10 @@
        return 0;
       availableCells -= leadingBlanks;
       if ((charactersWritten + availableCells) >= translatedLength)
+      {
        cellsToWrite = translatedLength - charactersWritten;
+       lastLineInStyle = 1;
+       }
       else
        {
          for (cellsToWrite = availableCells; cellsToWrite > 0;
@@ -2502,6 +2496,7 @@
 {
 /*Line or page skipping before body*/
   styleSpec->status = startBody;
+  lastLineInStyle = 0;
   if (ud->format_for == utd)
     return utd_startStyle ();
   if (!ud->paragraphs)
@@ -2639,7 +2634,6 @@
     }
   writeOutbuf ();
   ud->blank_lines = maximum (ud->blank_lines, style->lines_after);
-
   return 1;
 }

@@ -4209,7 +4203,7 @@
   return 1;
 }

-static void
+static int
 postponedStartActions ()
 {
   PageStatus curPageStatus = checkPageStatus ();
@@ -4244,6 +4238,7 @@
            return 0;
        }
     }
+  return 1;
 }

 static int
@@ -4903,3 +4898,4 @@
     output_xml (ud->doc);
   return 1;
 }
+
For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com

Other related posts:

  • » [liblouis-liblouisxml] [liblouisutdml] push by john.bo...@xxxxxxxxxxxxxxxxx - enhancements inspired by Bible transcription challenge on 2012-02-21 14:00 GMT - liblouisutdml