@@ -118,117 +118,187 @@ function add_math_symbols(dpath, fname)
118
118
end
119
119
120
120
#=
121
- standard | v7.0 | proposed | type
122
- ----------|-------|----------|------
123
- mscr | scr | sc | script
124
- msans | sans | ss | sans-serif
125
- Bbb | bb | ds | blackboard / doublestruck
126
- mfrak | frak | fr | fraktur
127
- mtt | tt | tt | mono
128
- mit | it | it | italic
129
- mitsans | isans | is | italic sans-serif
130
- mitBbb | bbi | id | italic blackboard / doublestruct
131
- mbf | bf | bd | bold
132
- mbfscr | bscr | bc | bold script
133
- mbfsans | bsans | bs | bold sans-serif
134
- mbffrak | bfrak | bf | bold fraktur
135
- mbfit | bi | bi | bold italic
136
- mbfitsans | bisans| bis | bold italic sans-serif
137
- | gr | greek
138
- it<greek> | ig | italic greek
139
- bf<greek> | bg | bold greek
140
- bi<greek> | big | bold italic greek
141
- bsans<greek> | bsg | bold sans-serif greek
142
- bisans<greek> | bisg | bold italic sans-serif greek
143
- | gv | greek variant
144
- mitvar<greek> | iv | italic greek variant
145
- mbfvar<greek> | bv | bold greek variant
146
- mbfitvar<greek> | biv | bold italic greek variant
147
- mbfsansvar<greek> | bsv | bold sans-serif greek variant
148
- mbfitsansvar<greek> | bisv | bold italic sans-serif greek variant
121
+
122
+ standard | v7.0 | new | type
123
+ ----------|---------|-------|-------------------------------
124
+ mscr | scr | c_ | script/cursive
125
+ msans | sans | s_ | sans-serif
126
+ Bbb | bb | d_ | blackboard / doublestruck
127
+ mfrak | frak | f_ | fraktur
128
+ mtt | tt | t_ | mono
129
+ mit | it | i_ | italic
130
+ mitsans | isans | is_ | italic sans-serif
131
+ mitBbb | bbi | id_ | italic blackboard / doublestruct
132
+ mbf | bf | b_ | bold
133
+ mbfscr | bscr | bc_ | bold script/cursive
134
+ mbfsans | bsans | bs_ | bold sans-serif
135
+ mbffrak | bfrak | bf_ | bold fraktur
136
+ mbfit | bi | bi_ | bold italic
137
+ mbfitsans | bisans | bis_ | bold italic sans-serif
138
+ <greek> | G | greek
139
+ it<greek> | i_G | italic greek
140
+ bf<greek> | b_G | bold greek
141
+ bi<greek> | bi_G | bold italic greek
142
+ bsans<greek> | bs_G | bold sans-serif greek
143
+ bisans<greek> | bis_G | bold italic sans-serif greek
144
+ var<greek> | V | greek variant
145
+ mitvar<greek> | i_V | italic greek variant
146
+ mbfvar<greek> | b_V | bold greek variant
147
+ mbfitvar<greek> | bi_V | bold italic greek variant
148
+ mbfsansvar<greek> | bs_V | bold sans-serif greek variant
149
+ mbfitsansvar<greek> | bis_V | bold italic sans-serif greek variant
149
150
150
151
i -> imath ı
151
152
=#
153
+ function str_chr (val)
154
+ isempty (val) && return " "
155
+ io = IOBuffer ()
156
+ for ch in val
157
+ print (io, hex (ch% UInt32,4 ), ' :' )
158
+ end
159
+ String (take! (io))[1 : end - 1 ]
160
+ end
161
+
162
+ function str_names (nameset)
163
+ io = IOBuffer ()
164
+ allnames = sort (collect (nameset))
165
+ for n in allnames
166
+ print (io, n, " " )
167
+ end
168
+ String (take! (io))
169
+ end
170
+
152
171
function add_name (dic:: Dict , val, nam)
153
- println (" \e [s$val \e [u\e [4C$nam " )
154
172
if haskey (dic, val)
155
173
push! (dic[val], nam)
174
+ disp[] && println (" \e [s$val \e [u\e [4C$(rpad (str_chr (val),20 )) " , str_names (dic[val]))
156
175
else
157
176
dic[val] = Set ((nam,))
177
+ disp[] && println (" \e [s$val \e [u\e [4C$(rpad (str_chr (val),20 ))$nam " )
178
+ end
179
+ end
180
+
181
+ function check_name (out:: Dict , dic:: Dict , val, nam, old)
182
+ oldval = get (dic, nam, " " )
183
+ # Check if short name is already in table with same value
184
+ oldval == " " && return (add_name (out, val, nam); true )
185
+ oldval != val && disp[] && println (" Conflict: $old => $val , $nam => $oldval " )
186
+ false
187
+ end
188
+
189
+ function replace_suffix (out, dic, val, nam, suffix, pref, list)
190
+ for (suf, rep) in list
191
+ suffix == suf && return check_name (out, dic, val, pref * rep, nam)
158
192
end
193
+ false
159
194
end
160
195
161
- function replace_suffix (dic, val, nam, off, pref, list)
196
+ #=
197
+ function replace_greek(out, dic, val, nam, off, pref, list)
162
198
for (suf, rep) in list
163
- nam[off: end ] == suf && (add_name (dic, val, pref * suf) ; return true )
199
+ if nam[off:end] == suf
200
+ return check_name(out, dic, val, pref * rep, nam) |
201
+ check_name(out, dic, val, pref[1:end-1] * suf, nam)
202
+ end
164
203
end
165
204
false
166
205
end
206
+ =#
167
207
168
- replace_all (dic, val, nam, off, grpref, gvpref, digpref) =
169
- replace_suffix (dic, val, nam, off, grpref, greek_letters) ||
170
- replace_suffix (dic, val, nam, off, gvpref, var_greek) ||
171
- replace_suffix (dic, val, nam, off, digpref, digits)
208
+ function replace_all (out, dic, val, nam, suffix, pref)
209
+ # replace_greek(out, dic, val, nam, off, pref * "G_", greek_letters) ||
210
+ # replace_greek(out, dic, val, nam, off, pref * "V_", var_greek) ||
211
+ replace_suffix (out, dic, val, nam, suffix, pref * " _" , digits)
212
+ end
172
213
173
214
function shorten_names (names:: Dict )
174
215
valtonam = Dict {String,Set{String}} ()
175
216
for (nam, val) in names
176
- for (oldnam, newnam) in replace_name
177
- nam == oldnam && (nam = newnam; break )
217
+ # handle combining accents, change from 'accent{X}' to 'X-accent'
218
+ if ! startswith (nam, " math" ) && sizeof (nam) > 3 &&
219
+ nam[end ]% UInt8 == ' }' % UInt8 && nam[end - 2 ]% UInt8 == ' {' % UInt8
220
+ ch = nam[end - 1 ]% UInt8
221
+ if ch - ' A' % UInt8 < 0x1a || ch - ' a' % UInt8 < 0x1a || ch - ' 0' % UInt8 < 0xa
222
+ # tst = string(nam[end-1], '-', nam[1:end-3])
223
+ # check_name(valtonam, names, val, tst, nam)
224
+ add_name (valtonam, val, nam)
225
+ continue
226
+ end
178
227
end
179
228
# Special handling of "up"/"mup" prefixes
180
- if startswith (" up" , nam )
229
+ if startswith (nam, " up" )
181
230
# Add it later when processing "mup" prefix if they have the same value
182
231
get (names, " m" * nam, " " ) == val && continue
183
- elseif startswith (" mup" , nam )
232
+ elseif startswith (nam, " mup" )
184
233
# If short form in table with same value, continue, otherwise, add short form
185
- upval = get (names, nam[2 : end ], " " ) # see if "up..." is in the table
186
- shortval = get (names, nam[4 : end ], " " ) # see if "..." is in the table
187
- val == shortval && continue # short name is already in table with same value
188
- add_name (valtonam, val, shortval == " " ? nam[4 : end ] : nam[2 : end ])
234
+ # upval = get(names, nam[2:end], "") # see if "up..." is in the table
235
+ # val == upval && continue # short name is already in table with same value
236
+ oldval = get (names, nam[4 : end ], " " ) # see if "..." is in the table
237
+ val == oldval && continue # short name is already in table with same value
238
+ check_name (valtonam, names, val, oldval == " " ? nam[4 : end ] : nam[2 : end ], nam)
189
239
continue
190
240
else
191
- for (pref, rep) in replace_prefix
192
- if startswith (pref, nam)
193
- tst = rep * nam[sizeof (pref)+ 1 : end ]
194
- if haskey (names, tst)
195
- print (" Conflict: $nam => $val with prefix replaced " )
196
- println (" $tst => $(collect (names[tst])) " )
197
- else
198
- nam = tst
199
- end
241
+ flg = false
242
+ nam in remove_name && continue
243
+ for (oldnam, newnam) in replace_name
244
+ if nam == oldnam
245
+ flg = check_name (valtonam, names, val, newnam, nam)
200
246
break
201
247
end
202
248
end
203
- end
204
- add_name (valtonam, val, nam)
205
- # Produce short forms for Greek and numbers
206
- siz = sizeof (nam)
207
- siz > 3 || continue
208
- replace_suffix (valtonam, val, nam, 1 , " gr" , greek_letters) && continue
209
- replace_suffix (valtonam, val, nam, 1 , " gv" , var_greek) && continue
210
- if nam[1 ] == ' i' && nam[2 ] == ' t'
211
- replace_all (valtonam, val, nam, 3 , " ig" , " iv" , " it" ) && continue
212
- elseif nam[1 ] == ' b'
213
- if nam[2 ] == ' f'
214
- replace_all (valtonam, val, nam, 3 , " bg" , " bv" , " bf" ) && continue
215
- elseif nam[2 ] == ' s' && siz > 6 && nam[3 ] == ' a' && nam[4 ] == ' n' && nam[5 ] == ' s'
216
- replace_all (valtonam, val, nam, 6 , " bsg" , " bsv" , " bs" ) && continue
217
- elseif nam[2 ] == ' i'
218
- if nam[3 ] == ' s' && siz > 7 && nam[4 ] == ' a' && nam[5 ] == ' n' && nam[6 ] == ' s'
219
- replace_all (valtonam, val, nam, 7 , " bisg" , " bisv" , " bis" ) && continue
220
- else
221
- replace_all (valtonam, val, nam, 3 , " big" , " biv" , " bi" ) && continue
249
+ flg && continue
250
+ if nam[1 ] in remove_lead_char
251
+ for pref in remove_prefix
252
+ startswith (nam, pref) || continue
253
+ flg = true
254
+ tst = nam[sizeof (pref)+ 1 : end ]
255
+ oldval = get (names, tst, " " )
256
+ oldval == val || (oldval == " " && add_name (valtonam, val, tst))
257
+ break
258
+ end
259
+ elseif nam[1 ] in replace_lead_char
260
+ for (pref, rep, repv7) in replace_prefix
261
+ startswith (nam, pref) || continue
262
+ suff = nam[sizeof (pref)+ 1 : end ]
263
+ flg = replace_all (valtonam, names, val, nam, suff, rep)
264
+ #=
265
+ if rep == "i"
266
+ flg = replace_all(valtonam, names, val, suff, "i")
267
+ elseif rep == "t" || rep == "d" || rep == "s" || rep == "c"
268
+ flg = replace_all(valtonam, names, val, suff, rep)
269
+ elseif rep == "" || rep[1] != 'b'
270
+ elseif rep == "b"
271
+ flg = replace_all(valtonam, names, val, suff, "b")
272
+ elseif rep == "sb"
273
+ flg = replace_all(valtonam, names, val, suff, "bs")
274
+ elseif rep == "ib"
275
+ flg = replace_all(valtonam, names, val, suff, "bi")
276
+ elseif rep == "cib"
277
+ flg = replace_all(valtonam, names, val, suff, "bic")
278
+ end
279
+ =#
280
+ flg || (flg = check_name (valtonam, names, val, rep * " _" * suff, nam))
281
+ # check_name(valtonam, names, val, repv7 * nam[sizeof(pref)+1:end], nam)
282
+ # flg = true
283
+ break
222
284
end
223
285
end
286
+ # Add short forms, if not already handled
287
+ flg && continue
224
288
end
289
+ # replace_suffix(valtonam, names, val, nam, 1, "G_", greek_letters) ||
290
+ # replace_suffix(valtonam, names, val, nam, 1, "V_", var_greek)
291
+ add_name (valtonam, val, nam)
225
292
end
226
293
# Split into two vectors
227
294
syms = Vector {String} ()
228
295
vals = Vector {String} ()
229
- for (val, names) in valtonam, nam in names
230
- push! (syms, nam)
231
- push! (vals, val)
296
+ for (val, namset) in valtonam
297
+ for nam in namset
298
+ startswith (nam, " math" ) && length (namset) > 1 && continue
299
+ push! (syms, nam)
300
+ push! (vals, val)
301
+ end
232
302
end
233
303
syms, vals
234
304
end
@@ -265,10 +335,14 @@ function make_tables()
265
335
println (countdup, " duplicates, " , countdiff, " overwritten out of " , length (sym_set),
266
336
" found in " , et[ind])
267
337
end
338
+ # Dump out set
339
+ disp[] && println (" LaTeX set:\n " , latex_set)
340
+ disp[] && println (" Differences:\n " , diff_set)
341
+
268
342
# Now, replace or remove prefixes and suffixes
269
343
symnam, symval = shorten_names (latex_set)
270
344
271
- println (length (symval), " distinct entities found" )
345
+ disp[] && println (length (symval), " distinct entities found\n " , symnam )
272
346
273
347
# We want to build a table of all the names, sort them, then create a StrTable out of them
274
348
srtnam = sortperm (symnam)
0 commit comments