~ubuntu-branches/debian/squeeze/sword/squeeze

« back to all changes in this revision

Viewing changes to src/modules/filters/gbfhtml.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Marsden, Jonathan Marsden, Dmitrijs Ledkovs, Closed Bugs
  • Date: 2009-05-30 11:55:55 UTC
  • mfrom: (1.3.1 upstream) (6.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090530115555-r427zsn3amivdpfu
Tags: 1.6.0+dfsg-1
[ Jonathan Marsden ]
* New upstream release. (Closes: #507960) (LP: #320558)
* debian/patches/02_libver.diff:
  - Bump SONAME to 8 -- SWORD 1.6 is not backward compatible with 1.5.11.
* debian/patches/series:
  - Remove 10_diatheke.diff -- included in upstream source.
* debian/patches/:
  - Remove several old unused .diff files.
  - Add 11_regex_only_when_needed.diff to conditionally include regex lib.
  - Add 12_fix_compiler_warnings.diff to remove all compiler warnings.
  - Add 13_fix_osis2mod_compression_default.diff from upstream svn.
  - Add 14_closing_section_not_chapter.diff from upstream svn.
* debian/libsword7.*: 
  - Rename to libsword8.*
  - Change libsword7 to libsword8 within files.
* debian/rules: 
  - SONAME bump to 8.
  - Set library version check to >= 1.6
* debian/control:
  - Change libsword7 to libsword8.
  - Add libsword7 to Conflicts.
  - Fix case of sword to SWORD in package descriptions.
  - Bump Standards-Version to 3.8.1 (no changes needed).
  - Fix section for libsword-dbg to avoid lintian warning.
* debian/rules:
  - Add DFSG get-orig-source target.
* debian/copyright:
  - Fix various mistakes in initial attempt to document copyrights.

[ Dmitrijs Ledkovs ]
* debian/rules: Added utils.mk to use missing-files target and call it on
  each build.
* debian/libsword-dev.install: Added libsword.la, previously missing.
* debian/libsword7.install: Added missing libicu translit files.
* debian/control:
  - Updated all uses of SWORD version to 1.6
  - Added libsword-dbg package
* debian/watch: Fixed a small mistake which was resulting in extra "."
  in final version name.
* debian/rules: simplified manpage processing.
* debian/libsword8.lintian-overrides: added override for module
  installation directory.
* debian/copyright: Updated with information about everyfile.
  Closes: #513448 LP: #322638
* debian/diatheke.examples: moved examples here from the diatheke.install
* debian/rules:
  - enabled shell script based testsuite
  - added commented out cppunit testsuite
* debian/patches/40_missing_includes.diff: 
  - added several missing stdio.h includes to prevent FTBFS of testsuite.

[ Closed Bugs ]
* FTBFS on intrepid (LP: #305172)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *                         gbfhtml.cpp  -   GBF to HTML filter 
 
3
 *                            -------------------
 
4
 *   begin                    : 2001-09-03
 
5
 *   copyright            : 2001 by CrossWire Bible Society
 
6
 *
 
7
 * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
 
8
 *      CrossWire Bible Society
 
9
 *      P. O. Box 2528
 
10
 *      Tempe, AZ  85280-2528
 
11
 *
 
12
 * This program is free software; you can redistribute it and/or modify it
 
13
 * under the terms of the GNU General Public License as published by the
 
14
 * Free Software Foundation version 2.
 
15
 *
 
16
 * This program is distributed in the hope that it will be useful, but
 
17
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
19
 * General Public License for more details.
 
20
 *
 
21
 */
 
22
 
 
23
#include <stdlib.h>
 
24
#include <gbfhtml.h>
 
25
#include <ctype.h>
 
26
 
 
27
SWORD_NAMESPACE_START
 
28
 
 
29
GBFHTML::GBFHTML() {
 
30
        setTokenStart("<");
 
31
        setTokenEnd(">");
 
32
        
 
33
        setTokenCaseSensitive(true);
 
34
 
 
35
        addTokenSubstitute("Rf", ")</small></font>");
 
36
        addTokenSubstitute("Rx", "</a>");
 
37
        addTokenSubstitute("FI", "<i>"); // italics begin
 
38
        addTokenSubstitute("Fi", "</i>");
 
39
        addTokenSubstitute("FB", "<n>"); // bold begin
 
40
        addTokenSubstitute("Fb", "</n>");
 
41
        addTokenSubstitute("FR", "<font color=\"#FF0000\">"); // words of Jesus begin
 
42
        addTokenSubstitute("Fr", "</font>");
 
43
        addTokenSubstitute("FU", "<u>"); // underline begin
 
44
        addTokenSubstitute("Fu", "</u>");
 
45
        addTokenSubstitute("FO", "<cite>"); //  Old Testament quote begin
 
46
        addTokenSubstitute("Fo", "</cite>");
 
47
        addTokenSubstitute("FS", "<sup>"); // Superscript begin// Subscript begin
 
48
        addTokenSubstitute("Fs", "</sup>");
 
49
        addTokenSubstitute("FV", "<sub>"); // Subscript begin
 
50
        addTokenSubstitute("Fv", "</sub>");
 
51
        addTokenSubstitute("TT", "<big>"); // Book title begin
 
52
        addTokenSubstitute("Tt", "</big>");
 
53
        addTokenSubstitute("PP", "<cite>"); //  poetry  begin
 
54
        addTokenSubstitute("Pp", "</cite>");
 
55
        addTokenSubstitute("Fn", "</font>"); //  font  end
 
56
        addTokenSubstitute("CL", "<br />"); //  new line
 
57
        addTokenSubstitute("CM", "<!P><br />"); //  paragraph <!P> is a non showing comment that can be changed in the front end to <P> if desired
 
58
        addTokenSubstitute("CG", ""); //  ???
 
59
        addTokenSubstitute("CT", ""); // ???
 
60
        addTokenSubstitute("JR", "<div align=\"right\">"); // right align begin
 
61
        addTokenSubstitute("JC", "<div align=\"center\">"); // center align begin
 
62
        addTokenSubstitute("JL", "</div>"); // align end
 
63
        
 
64
}
 
65
 
 
66
 
 
67
bool GBFHTML::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
 
68
        const char *tok;
 
69
        char val[128];
 
70
        char *valto;
 
71
        const char *num;
 
72
        MyUserData *u = (MyUserData *)userData;
 
73
 
 
74
        if (!substituteToken(buf, token)) {             
 
75
                // deal with OSIS note tags.  Just hide till OSISRTF            
 
76
                if (!strncmp(token, "note ", 5)) {
 
77
                        // let's stop text from going to output
 
78
                        u->suspendTextPassThru = true;
 
79
                }
 
80
                
 
81
                else if (!strncmp(token, "/note", 5)) {
 
82
                        u->suspendTextPassThru = false;
 
83
                }               
 
84
 
 
85
                else if (!strncmp(token, "w", 1)) {
 
86
                        // OSIS Word (temporary until OSISRTF is done)
 
87
                        valto = val;
 
88
                        num = strstr(token, "lemma=\"x-Strongs:");
 
89
                        if (num) {
 
90
                                for (num+=17; ((*num) && (*num != '\"')); num++)
 
91
                                        *valto++ = *num;
 
92
                                *valto = 0;
 
93
                                if (atoi((!isdigit(*val))?val+1:val) < 5627) {
 
94
                                        buf += " <small><em>&lt;";
 
95
                                        for (tok = (!isdigit(*val))?val+1:val; *tok; tok++)
 
96
                                                        buf += *tok;
 
97
                                        buf += "&gt;</em></small> ";                                    
 
98
                                }
 
99
                        } else {
 
100
                                num = strstr(token, "lemma=\"strong:");
 
101
                                if (num) {
 
102
                                        for (num+=14; ((*num) && (*num != '\"')); num++)
 
103
                                                *valto++ = *num;
 
104
                                        *valto = 0;
 
105
                                        if (atoi((!isdigit(*val))?val+1:val) < 5627) {
 
106
                                                buf += " <small><em>&lt;";
 
107
                                                for (tok = (!isdigit(*val))?val+1:val; *tok; tok++)
 
108
                                                                buf += *tok;
 
109
                                                buf += "&gt;</em></small> ";                                    
 
110
                                        }
 
111
                                }
 
112
                        }
 
113
                        valto = val;
 
114
                        num = strstr(token, "morph=\"x-Robinson:");
 
115
                        if (num) {
 
116
                                for (num+=18; ((*num) && (*num != '\"')); num++)
 
117
                                        *valto++ = *num;
 
118
                                *valto = 0;
 
119
                                // normal robinsons tense
 
120
                                buf += " <small><em>(";
 
121
                                for (tok = val; *tok; tok++)
 
122
                                                buf += *tok;            
 
123
                                buf += ")</em></small> ";                                       
 
124
                        }
 
125
                }
 
126
                
 
127
                else if (!strncmp(token, "WG", 2) || !strncmp(token, "WH", 2)) { // strong's numbers
 
128
                        buf += " <small><em>&lt;";
 
129
                        for (tok = token + 2; *tok; tok++)
 
130
                                        buf += *tok;
 
131
                        buf += "&gt;</em></small> ";
 
132
                }
 
133
 
 
134
                else if (!strncmp(token, "WTG", 3) || !strncmp(token, "WTH", 3)) { // strong's numbers tense
 
135
                        buf += " <small><em>&lt;";
 
136
                        for (tok = token + 3; *tok; tok++)
 
137
                                if(*tok != '\"')
 
138
                                        buf += *tok;
 
139
                        buf += ")</em></small> ";
 
140
                }
 
141
 
 
142
                else if (!strncmp(token, "RX", 2)) {
 
143
                        buf += "<i>";
 
144
                        for (tok = token + 3; *tok; tok++) {
 
145
                          if(*tok != '<' && *tok+1 != 'R' && *tok+2 != 'x') {
 
146
                            buf += *tok;
 
147
                          }
 
148
                          else {
 
149
                            break;
 
150
                          }
 
151
                        }
 
152
                        buf += "</i>";
 
153
                }
 
154
 
 
155
                else if (!strncmp(token, "RB", 2)) {
 
156
                        buf += "<i>";
 
157
                        u->hasFootnotePreTag = true;
 
158
                }
 
159
 
 
160
                else if (!strncmp(token, "RF", 2)) {
 
161
                        if (u->hasFootnotePreTag) {
 
162
                                u->hasFootnotePreTag = false;
 
163
                                buf += "</i> ";
 
164
                        }
 
165
                        buf += "<font color=\"#800000\"><small> (";
 
166
                }
 
167
 
 
168
                else if (!strncmp(token, "FN", 2)) {
 
169
                        buf += "<font face=\"";
 
170
                        for (tok = token + 2; *tok; tok++)                              
 
171
                                if(*tok != '\"')                        
 
172
                                        buf += *tok;
 
173
                        buf += "\">";
 
174
                }
 
175
 
 
176
                else if (!strncmp(token, "CA", 2)) {    // ASCII value
 
177
                        buf += (char)atoi(&token[2]);
 
178
                }
 
179
                
 
180
                else {
 
181
                        return false;
 
182
                }
 
183
        }
 
184
        return true;
 
185
}
 
186
 
 
187
SWORD_NAMESPACE_END