[r200]: trunk / tools / html2lex.patch  Maximize  Restore  History

Download this file

155 lines (148 with data), 5.2 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
--- html2lex.c.orig 2011-05-06 20:36:25.000000000 -0700
+++ html2lex.c 2011-05-06 20:40:04.000000000 -0700
@@ -1913,6 +1913,12 @@
}
}
+bool in_header;
+int in_math;
+int in_verb;
+int in_alltt;
+
+
void print_str_(FILE *fout, char *str);
void print_str_(FILE *fout, char *str)
{
@@ -1980,10 +1986,13 @@
else if ((unsigned char)*str >= ' ' && (unsigned char)*str <= HIGHASCII)
ch = *str;
if (fout)
- if ( ch == '_' || ch == '#' || ch == '[' || ch == ']'
+ if ( ch == '#' || ch == '[' || ch == ']'
+ || ch == '-' || ch == '\\' || ch == '\'' || ch == ','
+ || ch == '`' || ch == '<' || ch == '='
|| ch == '{' || ch == '}' || ch == '%' || ch == '&'
- || ch == '~' || ch == '\0')
- fputc('.', fout);
+ || ch == '~' || ch == '\0') {
+ fprintf(fout, "_%2d", (int)ch);
+ }
else
fputc(ch, fout);
}
@@ -2012,6 +2021,11 @@
break;
if (codes[i] == '\0')
fputc('%', fout);
+ else if (codes[i] == 'a')
+ {
+ print_str(fout, strs[i], NULL, "", 0,in_math, in_verb, in_alltt);
+ str++;
+ }
else
{ print_str_(fout, strs[i]);
str++;
@@ -2021,12 +2035,6 @@
/* Generation state values */
-bool in_header;
-int in_math;
-int in_verb;
-int in_alltt;
-
-
#define URL_not 0
#define URL_ftp 1
#define URL_mailto 2
@@ -2279,11 +2287,12 @@
/* correct .html file: */
else if (href_status == 0)
- { char *strs[4];
+ { char *strs[5];
char filenr[10];
sprintf(filenr, opt_filenr, find_file(file)->nr);
strs[0] = filenr;
- strs[1] = fragil_env ? c_protect : "";
+ strs[1] = atext;
+ strs[2] = fragil_env ? c_protect : "";
if ( in_header
? opt_href_in_header == OPT_NORMAL
@@ -2294,25 +2303,25 @@
/* ignore */;
else if (name[0] == '\0')
print_f(fout, latex_fmt[0] != '\0' ? latex_fmt : opt_cf,
- "fp", strs);
+ "fap", strs);
else
- { strs[2] = name;
+ { strs[3] = name;
print_f(fout, latex_fmt[0] != '\0' ? latex_fmt : opt_cf_n,
- "fpn", strs);
+ "fapn", strs);
}
}
else if (f_kind == FOOTNOTE_KIND_MARK)
fputs(c_footmark, fout);
else
- { strs[2] = f_kind == FOOTNOTE_KIND_NORMAL
+ { strs[3] = f_kind == FOOTNOTE_KIND_NORMAL
? c_footnote : c_foottext;
if (name[0] == '\0')
print_f(fout, latex_fmt[0] != '\0' ? latex_fmt : opt_f_cf,
- "fpF", strs);
+ "fapF", strs);
else
- { strs[3] = name;
+ { strs[4] = name;
print_f(fout, latex_fmt[0] != '\0' ? latex_fmt : opt_f_cf_n,
- "fpFn", strs);
+ "fapFn", strs);
}
}
}
@@ -2615,8 +2624,8 @@
#define H_DEL 48
{ "del", C_YES, T_CHAR, 0, "", "" },
#define H_PRE 49
- { "pre", C_YES, T_VERB, LATEX_KIND_VERB, "\\begin{verbatim} ",
- "\\end{verbatim}\n" },
+ { "pre", C_YES, T_VERB, LATEX_KIND_ALLTT, "\\begin{alltt} ",
+ "\\end{alltt}\n" },
#define H_XMP 50
{ "xmp", C_YES, T_VERB, LATEX_KIND_VERB, "\\begin{verbatim} ",
"\\end{verbatim}\n" },
@@ -3212,7 +3221,8 @@
|| (in_header && tagkind == T_P)
|| (item_depth >= 4 && tagkind == T_LIST)
|| in_verb
- || (in_alltt && tagkind != T_CHAR))
+ || (in_alltt && !(latex_kind & LATEX_KIND_ALLTT) &&
+ tagkind != T_CHAR))
{ if (freport && option_warn)
fprintf(freport,
"%s (%d) : <%s> ignored in LaTeX.\n",
@@ -4522,7 +4532,7 @@
LATEX_CLOSES(tagnr)
else if (OPEN_TAG(T_CHAR))
{
- if (tagnr == H_FONT)
+ if (tagnr == H_FONT || tagnr == H_CODE)
{
LATEX_OPEN(tagnr) // FONT may be nested
}
@@ -4630,10 +4640,11 @@
{ empty_line = FALSE;
empty_item = FALSE;
}
- add_to_comment(ch, &i);
- ch = (char)fgetc(fin);
if (active_href && atext_len < MAX_AT)
atext[atext_len++] = ch;
+ else
+ add_to_comment(ch, &i);
+ ch = (char)fgetc(fin);
}
add_to_comment('\0', &i);
if (no_header && !no_copy && !empty_line && fout != NULL)
@@ -5167,4 +5178,3 @@
return 0;
}
-