From grdetil@scrc.umanitoba.ca Fri Oct 29 15:06:57 1999 Date: Fri, 29 Oct 1999 16:54:59 -0500 (CDT) From: Gilles Detillieux To: htdig@htdig.org Subject: [htdig] [PATCH] highlighting and page number separator options for htsearch 3.1.3 Hi, all. This is a variation on a patch posted to htdig3-dev on Wednesday. It will also be available on http://www.htdig.org/files/contrib/other/ . This patch adds start_highlight, end_highlight, and page_number_separator attributes to htsearch, to improve configurability of output formats. It's an adaptation of a similar patch by Sergey Yu. Abdurashitov, posted to the htdig3-dev mailing list, with improvements and documentation added. --- htdig-3.1.3/htcommon/defaults.cc.orig Wed Sep 22 11:18:39 1999 +++ htdig-3.1.3/htcommon/defaults.cc Fri Oct 29 15:54:40 1999 @@ -48,6 +48,7 @@ ConfigDefaults defaults[] = {"doc_index", "${database_base}.docs.index"}, {"doc_list", "${database_base}.docs"}, {"end_ellipses", " ..."}, + {"end_highlight", ""}, {"endings_affix_file", "${common_dir}/english.aff"}, {"endings_dictionary", "${common_dir}/english.0"}, {"endings_root2word_db", "${common_dir}/root2word.db"}, @@ -107,6 +108,7 @@ ConfigDefaults defaults[] = {"no_title_text", "filename"}, {"nothing_found_file", "${common_dir}/nomatch.html"}, {"page_list_header", "
Pages:
"}, + {"page_number_separator", "\" \""}, {"prefix_match_character", "*"}, {"prev_page_text", "[prev]"}, {"remove_bad_urls", "true"}, @@ -126,6 +128,7 @@ ConfigDefaults defaults[] = {"star_image", "${image_url_prefix}/star.gif"}, {"star_patterns", ""}, {"start_ellipses", "... "}, + {"start_highlight", ""}, {"start_url", "http://www.htdig.org/"}, {"substring_max_words", "25"}, {"synonym_db", "${common_dir}/synonyms.db"}, --- htdig-3.1.3/htdoc/attrs.html.orig Wed Oct 20 11:37:52 1999 +++ htdig-3.1.3/htdoc/attrs.html Fri Oct 29 15:51:06 1999 @@ -1232,6 +1232,53 @@
+ + end_highlight +
+
+
+
+ type: +
+
+ string +
+
+ used by: +
+
+ htsearch +
+
+ default: +
+
+ </strong> +
+
+ description: +
+
+ When excerpts are displayed in the search output, + matched words will be highlighted using + start_highlight + and this string. You should ensure that + highlighting tags are balanced, that is, this + string should close any formatting tag opened + by start_highlight. +
+
+ example: +
+
+ end_highlight: </font> +
+
+
+
+
+
+
endings_affix_file
@@ -1479,13 +1526,17 @@
This is the maximum number of characters the displayed excerpt will be limited to. The first matched word will - be bolded in the middle of the excerpt so that there is + be highlighted in the middle of the excerpt so that there is some surrounding context.
The start_ellipses and end_ellipses are used to indicate that the document contains text before and after the displayed excerpt respectively. + The start_highlight + and end_highlight + are used to specify what formatting tags are used to + highlight matched words.
example: @@ -4206,6 +4257,65 @@
+ + page_number_separator +
+
+
+
+ type: +
+
+ quoted string list +
+
+ used by: +
+
+ htsearch +
+
+ default: +
+
+ " " +
+
+ description: +
+
+ The text strings in this list will be + used when putting together the PAGELIST + variable, for use in templates or the + + search_results_footer file, when search + results fit on more than page. The PAGELIST + is the list of links at the bottom of the + search results page. The strings in the + list will be used in rotation, and will + separate individual entries taken from + page_number_text and + no_page_number_text. + There can be as many or as few strings in the + list as you like. If there are not enough for + the number of pages listed, it goes back to + the start of the list. If the list is empty, + a space is used. The text strings can contain + HTML tags. The strings need to be quoted if they + contain spaces, or to specify an empty string. +
+
+ example: +
+
+ page_number_separator: "</td> <td>" +
+
+
+
+
+
+
page_number_text
@@ -5559,6 +5669,53 @@
+ + start_highlight +
+
+
+
+ type: +
+
+ string +
+
+ used by: +
+
+ htsearch +
+
+ default: +
+
+ <strong> +
+
+ description: +
+
+ When excerpts are displayed in the search + output, matched words will be highlighted using + this string and + end_highlight. You should ensure that + highlighting tags are balanced, that is, any + formatting tags that this string opens should + be closed by end_highlight. +
+
+ example: +
+
+ start_highlight: <font color="#FF0000"> +
+
+
+
+
+
+
start_url
@@ -6732,7 +6889,7 @@ Andrew Scherpbier <andrew@contigo.com> -Last modified: Fri Aug 6 15:00:15 EDT 1999 +Last modified: Fri Oct 29 16:50:59 EDT 1999 --- htdig-3.1.3/htdoc/cf_byname.html.orig Wed Sep 22 11:18:41 1999 +++ htdig-3.1.3/htdoc/cf_byname.html Fri Oct 29 15:57:42 1999 @@ -47,6 +47,7 @@
E
* end_ellipses
+ * end_highlight
* endings_affix_file
* endings_dictionary
* endings_root2word_db
@@ -123,6 +124,7 @@

P
* page_list_header
+ * page_number_separator
* page_number_text
* pdf_parser
* prefix_match_character
@@ -148,6 +150,7 @@ * star_image
* star_patterns
* start_ellipses
+ * start_highlight
* start_url
* substring_max_words
* synonym_db
--- htdig-3.1.3/htdoc/cf_byprog.html.orig Wed Sep 22 11:18:41 1999 +++ htdig-3.1.3/htdoc/cf_byprog.html Fri Oct 29 15:58:35 1999 @@ -122,6 +122,7 @@ * doc_db
* doc_index
* end_ellipses
+ * end_highlight
* endings_root2word_db
* endings_word2root_db
* excerpt_length
@@ -147,6 +148,7 @@ * nothing_found_file
* no_title_text
* page_list_header
+ * page_number_separator
* page_number_text
* prefix_match_character
* prev_page_text
@@ -160,6 +162,7 @@ * star_image
* star_patterns
* start_ellipses
+ * start_highlight
* substring_max_words
* synonym_db
* template_map
--- htdig-3.1.3/htsearch/Display.cc.orig Wed Sep 22 11:18:44 1999 +++ htdig-3.1.3/htsearch/Display.cc Fri Oct 29 15:38:08 1999 @@ -498,6 +498,7 @@ Display::setVariables(int pageNumber, Li char *p; QuotedStringList pnt(config["page_number_text"], " \t\r\n"); QuotedStringList npnt(config["no_page_number_text"], " \t\r\n"); + QuotedStringList sep(config["page_number_separator"], " \t\r\n"); if (nPages > config.Value("maximum_pages", 10)) nPages = config.Value("maximum_pages"); for (i = 1; i <= nPages; i++) @@ -507,7 +508,7 @@ Display::setVariables(int pageNumber, Li p = npnt[i - 1]; if (!p) p = form("%d", i); - *str << p << ' '; + *str << p; } else { @@ -517,8 +518,10 @@ Display::setVariables(int pageNumber, Li *str << "" << p << " "; + *str << tmp << "\">" << p << ""; } + if (i != nPages) + *str << (sep.Count() > 0) ? sep[(i-1)%sep.Count()] : " "; } vars.Add("PAGELIST", str); } @@ -1058,6 +1061,8 @@ Display::excerpt(DocumentRef *ref, Strin char * Display::hilight(char *str, String urlanchor, int fanchor) { + static char *start_highlight = config["start_highlight"]; + static char *end_highlight = config["end_highlight"]; static String result; int pos; int which, length; @@ -1069,13 +1074,13 @@ Display::hilight(char *str, String urlan { result.append(str, pos); ww = (WeightWord *) (*searchWords)[which]; - result << ""; + result << start_highlight; if (first && fanchor) result << ""; result.append(str + pos, length); if (first && fanchor) result << ""; - result << ""; + result << end_highlight; str += pos + length; first = 0; } -- Gilles R. Detillieux E-mail: Spinal Cord Research Centre WWW: http://www.scrc.umanitoba.ca/~grdetil Dept. Physiology, U. of Manitoba Phone: (204)789-3766 Winnipeg, MB R3E 3J7 (Canada) Fax: (204)789-3930 ------------------------------------ To unsubscribe from the htdig mailing list, send a message to htdig@htdig.org containing the single word unsubscribe in the SUBJECT of the message.