about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/GridText.c8
-rw-r--r--src/HTML.c15
-rw-r--r--src/LYGlobalDefs.h3
-rw-r--r--src/LYMain.c11
-rw-r--r--src/LYOptions.c50
-rw-r--r--src/LYReadCFG.c3
-rw-r--r--src/LYrcFile.c4
-rw-r--r--src/LYrcFile.h3
8 files changed, 80 insertions, 17 deletions
diff --git a/src/GridText.c b/src/GridText.c
index 2738a26b..885141ce 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: GridText.c,v 1.295 2017/07/02 20:01:22 tom Exp $
+ * $LynxId: GridText.c,v 1.302 2017/07/04 17:27:07 tom Exp $
  *
  *		Character grid hypertext object
  *		===============================
@@ -5760,11 +5760,11 @@ void HText_endAppend(HText *text)
     /*
      * Get the first line.
      */
-    if ((line_ptr = FirstHTLine(text)) != 0) {
+    if (LYtrimBlankLines && (line_ptr = FirstHTLine(text)) != 0) {
 	/*
-	 * Remove the blank lines at the end of document.
+	 * Remove blank lines at the end of the document.
 	 */
-	while (text->last_line->data[0] == '\0' && text->Lines > 2) {
+	while (text->last_line->data[0] == '\0' && text->Lines > 0) {
 	    HTLine *next_to_the_last_line = text->last_line->prev;
 
 	    CTRACE((tfp, "GridText: Removing bottom blank line: `%s'\n",
diff --git a/src/HTML.c b/src/HTML.c
index 96fb80b8..c9ab9395 100644
--- a/src/HTML.c
+++ b/src/HTML.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTML.c,v 1.171 2017/07/02 19:57:04 tom Exp $
+ * $LynxId: HTML.c,v 1.173 2017/07/04 20:05:01 tom Exp $
  *
  *		Structured stream to Rich hypertext converter
  *		============================================
@@ -1984,14 +1984,15 @@ static int HTML_start_element(HTStructured * me, int element_number,
     case HTML_BR:
 	UPDATE_STYLE;
 	CHECK_ID(HTML_GEN_ID);
-	/* Add a \r (new line) if these three conditions are true:
-	 *   1. We are not collapsing BR's, and
-	 *   2. The previous line has text on it, or
-	 *   3. This line has text on it.
-	 * Otherwise, don't do anything. -DH 980814, TD 980827
+	/* Add a \r (new line) if these conditions are true:
+	 *   * We are not collapsing BR's (and either we are not trimming
+	 *     blank lines, or the preceding line is non-empty), or
+	 *   * The current line has text on it.
+	 * Otherwise, don't do anything. -DH 19980814, TD 19980827/20170704
 	 */
 	if ((LYCollapseBRs == FALSE &&
-	     !HText_PreviousLineEmpty(me->text, FALSE)) ||
+	     (!LYtrimBlankLines ||
+	      !HText_PreviousLineEmpty(me->text, FALSE))) ||
 	    !HText_LastLineEmpty(me->text, FALSE)) {
 	    HText_setLastChar(me->text, ' ');	/* absorb white space */
 	    HText_appendCharacter(me->text, '\r');
diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h
index 0e27a767..6ee3f81c 100644
--- a/src/LYGlobalDefs.h
+++ b/src/LYGlobalDefs.h
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYGlobalDefs.h,v 1.141 2015/12/18 00:35:49 tom Exp $
+ * $LynxId: LYGlobalDefs.h,v 1.142 2017/07/03 23:10:31 tom Exp $
  *
  * global variable definitions
  */
@@ -225,6 +225,7 @@ extern "C" {
     extern BOOLEAN LYinternal_flag;	/* don't need fresh copy, was internal link */
     extern BOOLEAN LYoverride_no_cache;		/* don't need fresh copy, from history */
     extern BOOLEAN LYresubmit_posts;
+    extern BOOLEAN LYtrimBlankLines;
     extern BOOLEAN LYtrimInputFields;
     extern BOOLEAN LYxhtml_parsing;
     extern BOOLEAN bold_H1;
diff --git a/src/LYMain.c b/src/LYMain.c
index fcb87baf..e38ba5bb 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYMain.c,v 1.261 2017/04/27 22:34:12 tom Exp $
+ * $LynxId: LYMain.c,v 1.265 2017/07/03 23:31:21 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTTP.h>
@@ -204,6 +204,7 @@ BOOLEAN LYforce_no_cache = FALSE;
 BOOLEAN LYinternal_flag = FALSE;	/* override no-cache b/c internal link */
 BOOLEAN LYoverride_no_cache = FALSE;	/*override no-cache b/c history etc */
 BOOLEAN LYresubmit_posts = ALWAYS_RESUBMIT_POSTS;
+BOOLEAN LYtrimBlankLines = TRUE;
 BOOLEAN LYtrimInputFields = FALSE;
 BOOLEAN LYxhtml_parsing = FALSE;
 BOOLEAN bold_H1 = FALSE;
@@ -3412,6 +3413,10 @@ outputs for -source dumps"
       "=FILENAME\nread keystroke commands from the given file\n(see -cmd_log)"
    ),
 #endif
+   PARSE_SET(
+      "collapse_br_tags", 4|TOGGLE_ARG,		LYCollapseBRs,
+      "toggles collapsing of BR tags"
+   ),
 #ifdef USE_SLANG
    PARSE_FUN(
       "color",		4|FUNCTION_ARG,		color_fun,
@@ -3978,6 +3983,10 @@ bug which treated '>' as a co-terminator for\ndouble-quotes and tags"
       "traverse all http links derived from startfile"
    ),
    PARSE_SET(
+      "trim_blank_lines", 2|TOGGLE_ARG,		LYtrimBlankLines,
+      "\ntoggle trimming of leading/trailing/collapsed-br blank lines"
+   ),
+   PARSE_SET(
       "trim_input_fields", 2|SET_ARG,		LYtrimInputFields,
       "\ntrim input text/textarea fields in forms"
    ),
diff --git a/src/LYOptions.c b/src/LYOptions.c
index 5100d940..eaee6be9 100644
--- a/src/LYOptions.c
+++ b/src/LYOptions.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYOptions.c,v 1.172 2017/07/02 20:07:12 tom Exp $ */
+/* $LynxId: LYOptions.c,v 1.174 2017/07/04 20:28:05 tom Exp $ */
 #include <HTUtils.h>
 #include <HTFTP.h>
 #include <HTTP.h>		/* 'reloading' flag */
@@ -2308,6 +2308,24 @@ static OptValues verbose_images_type_values[] =
     {0, 0, 0}
 };
 
+static const char *collapse_br_tags_string = RC_COLLAPSE_BR_TAGS;
+static OptValues collapse_br_tags_values[] =
+{
+	/* LYCollapseBRs variable */
+    {FALSE, N_("OFF"), "OFF"},
+    {TRUE, N_("collapse"), "ON"},
+    {0, 0, 0}
+};
+
+static const char *trim_blank_lines_string = RC_TRIM_BLANK_LINES;
+static OptValues trim_blank_lines_values[] =
+{
+	/* LYtrimBlankLines variable */
+    {FALSE, N_("OFF"), "OFF"},
+    {TRUE, N_("trim-lines"), "ON"},
+    {0, 0, 0}
+};
+
 /*
  * Bookmark Options
  */
@@ -3105,6 +3123,24 @@ int postoptions(DocInfo *newdoc)
 	    }
 	}
 
+	/* Collapse BR Tags: ON/OFF */
+	if (!strcmp(data[i].tag, collapse_br_tags_string)
+	    && GetOptValues(collapse_br_tags_values, data[i].value, &code)) {
+	    if (LYCollapseBRs != code) {
+		LYCollapseBRs = (BOOLEAN) code;
+		need_reload = TRUE;
+	    }
+	}
+
+	/* Trim Blank Lines: ON/OFF */
+	if (!strcmp(data[i].tag, trim_blank_lines_string)
+	    && GetOptValues(trim_blank_lines_values, data[i].value, &code)) {
+	    if (LYtrimBlankLines != code) {
+		LYtrimBlankLines = (BOOLEAN) code;
+		need_reload = TRUE;
+	    }
+	}
+
 	/* VI Keys: ON/OFF */
 	if (!strcmp(data[i].tag, vi_keys_string)
 	    && GetOptValues(bool_values, data[i].value, &code)) {
@@ -4007,6 +4043,18 @@ static int gen_options(char **newfile)
     PutOptValues(fp0, verbose_img, verbose_images_type_values);
     EndSelect(fp0);
 
+    /* Collapse BR Tags: ON/OFF */
+    PutLabel(fp0, gettext("Collapse BR tags"), collapse_br_tags_string);
+    BeginSelect(fp0, collapse_br_tags_string);
+    PutOptValues(fp0, LYCollapseBRs, collapse_br_tags_values);
+    EndSelect(fp0);
+
+    /* Trim blank lines: ON/OFF */
+    PutLabel(fp0, gettext("Trim blank lines"), trim_blank_lines_string);
+    BeginSelect(fp0, trim_blank_lines_string);
+    PutOptValues(fp0, LYtrimBlankLines, trim_blank_lines_values);
+    EndSelect(fp0);
+
     /*
      * Headers Transferred to Remote Servers
      */
diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c
index 7524c0a5..6552ae57 100644
--- a/src/LYReadCFG.c
+++ b/src/LYReadCFG.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYReadCFG.c,v 1.189 2016/11/24 15:35:29 tom Exp $
+ * $LynxId: LYReadCFG.c,v 1.190 2017/07/03 23:21:43 tom Exp $
  */
 #ifndef NO_RULES
 #include <HTRules.h>
@@ -1740,6 +1740,7 @@ static Config_Type Config_Table [] =
 #endif
      PARSE_PRG(RC_TOUCH_PATH,           ppTOUCH),
      PARSE_SET(RC_TRACK_INTERNAL_LINKS, track_internal_links),
+     PARSE_SET(RC_TRIM_BLANK_LINES,     LYtrimBlankLines),
      PARSE_SET(RC_TRIM_INPUT_FIELDS,    LYtrimInputFields),
 #ifdef EXEC_LINKS
      PARSE_DEF(RC_TRUSTED_EXEC,         EXEC_PATH),
diff --git a/src/LYrcFile.c b/src/LYrcFile.c
index 2c39c119..e42d3f65 100644
--- a/src/LYrcFile.c
+++ b/src/LYrcFile.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYrcFile.c,v 1.96 2016/11/24 16:42:46 tom Exp $ */
+/* $LynxId: LYrcFile.c,v 1.99 2017/07/04 20:30:03 tom Exp $ */
 #include <HTUtils.h>
 #include <HTFTP.h>
 #include <LYUtils.h>
@@ -380,6 +380,7 @@ correctly on your screen you may try changing to a different 8 bit\n\
 set or using the 7 bit character approximations.\n\
 Current valid characters sets are:\n\
 ")),
+    MAYBE_SET(RC_COLLAPSE_BR_TAGS,      LYCollapseBRs,      MSG_ENABLE_LYNXRC),
     PARSE_LIS(RC_COOKIE_ACCEPT_DOMAINS, LYCookieAcceptDomains, N_("\
 cookie_accept_domains and cookie_reject_domains are comma-delimited\n\
 lists of domains from which Lynx should automatically accept or reject\n\
@@ -620,6 +621,7 @@ presented regardless of user mode.\n\
 ")),
     MAYBE_FUN(RC_TAGSOUP,               get_tagsoup,        put_tagsoup,
               MSG_ENABLE_LYNXRC),
+    MAYBE_SET(RC_TRIM_BLANK_LINES,      LYtrimBlankLines,   MSG_ENABLE_LYNXRC),
     MAYBE_SET(RC_UNDERLINE_LINKS,       LYUnderlineLinks,   MSG_ENABLE_LYNXRC),
     PARSE_ENU(RC_USER_MODE,             user_mode,          tbl_user_mode, N_("\
 user_mode specifies the users level of knowledge with Lynx.  The\n\
diff --git a/src/LYrcFile.h b/src/LYrcFile.h
index 32003b66..dd2f99d2 100644
--- a/src/LYrcFile.h
+++ b/src/LYrcFile.h
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYrcFile.h,v 1.48 2015/12/18 01:58:05 tom Exp $
+ * $LynxId: LYrcFile.h,v 1.49 2017/07/03 23:20:33 tom Exp $
  */
 #ifndef LYRCFILE_H
 #define LYRCFILE_H
@@ -257,6 +257,7 @@
 #define RC_TN3270_PATH                  "tn3270_path"
 #define RC_TOUCH_PATH                   "touch_path"
 #define RC_TRACK_INTERNAL_LINKS         "track_internal_links"
+#define RC_TRIM_BLANK_LINES             "trim_blank_lines"
 #define RC_TRIM_INPUT_FIELDS            "trim_input_fields"
 #define RC_TRUSTED_EXEC                 "trusted_exec"
 #define RC_TRUSTED_LYNXCGI              "trusted_lynxcgi"