This file is indexed.

/usr/share/gnucash/scm/html-style-info.scm is in gnucash-common 1:2.6.15-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; html-style-info.scm : generate HTML programmatically, with support
;; for simple style elements. 
;; Copyright 2000 Bill Gribble <grib@gnumatic.com>
;; 
;; This program is free software; you can redistribute it and/or    
;; modify it under the terms of the GNU General Public License as   
;; published by the Free Software Foundation; either version 2 of   
;; the License, or (at your option) any later version.              
;;                                                                  
;; This program is distributed in the hope that it will be useful,  
;; but WITHOUT ANY WARRANTY; without even the implied warranty of   
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    
;; GNU General Public License for more details.                     
;;                                                                  
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, contact:
;;
;; Free Software Foundation           Voice:  +1-617-542-5942
;; 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
;; Boston, MA  02110-1301,  USA       gnu@gnu.org
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; <html-markup-style-info> class 
;; this is what's stored for tags in the style hash tables. 
;; literal data types have their own style record type,
;; <html-data-style-info>
;;
;;  constructor takes pairs of args :
;;  (gnc:make-html-markup-style-info field1 value1 field2 value2 ...)
;; 
;;  values for field (should be passed as symbols):
;;  tag         : string for start tag
;;  attributes  : hash of attribute to value (unsafe!)
;;  attribute   : single attribute-value pair in a list 
;;  font-face   : string for <font face="">
;;  font-size   : string for <font size="">
;;  font-color  : color (a valid HTML color spec)
;;  closing-font-tag: private data (computed from font-face,
;;                                  font-size, font-color)
;;                    don't set directly, please!
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(define <html-markup-style-info> 
  (make-record-type "<html-markup-style-info>"
                    '(tag 
                      attributes
                      font-face 
                      font-size 
                      font-color
		      closing-font-tag?
                      inheritable?)))

(define gnc:html-markup-style-info?
  (record-predicate <html-markup-style-info>))

(define gnc:make-html-markup-style-info-internal 
  (record-constructor <html-markup-style-info>))

(define (gnc:make-html-markup-style-info . rest)
  (let ((retval (gnc:make-html-markup-style-info-internal 
                 #f (make-hash-table) #f #f #f #f #t)))
    (apply gnc:html-markup-style-info-set! retval rest)
    retval))

(define (gnc:html-markup-style-info-set! style . rest)
  (let loop ((arglist rest))
    (if (and (list? arglist)
             (not (null? arglist))
             (not (null? (cdr arglist))))
        (let* ((field (car arglist))
               (value (cadr arglist)))
          (if (eq? field 'attribute)
              (if (list? value)
                  (gnc:html-markup-style-info-set-attribute!
                   style (car value) 
		   (if (null? (cdr value))
		       #f
		       (cadr value))))
	      (begin 
		(if (memq field '(font-size font-face font-color))
		    (gnc:html-markup-style-info-set-closing-font-tag!
		     style
		     (not (eq? value #f))))
		(let ((modifier 
                     (record-modifier <html-markup-style-info> field)))
                (modifier style value))))
          (loop (cddr arglist)))))
  style)

(define gnc:html-markup-style-info-tag
  (record-accessor <html-markup-style-info> 'tag))

(define gnc:html-markup-style-info-set-tag!
  (record-modifier <html-markup-style-info> 'tag))

(define gnc:html-markup-style-info-attributes
  (record-accessor <html-markup-style-info> 'attributes))

(define gnc:html-markup-style-info-set-attributes!
  (record-modifier <html-markup-style-info> 'attributes))

(define gnc:html-markup-style-info-font-face
  (record-accessor <html-markup-style-info> 'font-face))

(define gnc:html-markup-style-info-set-font-face-internal!
  (record-modifier <html-markup-style-info> 'font-face))

(define (gnc:html-markup-style-info-set-font-face! record value)
  (begin
    (gnc:html-markup-style-info-set-closing-font-tag!
     record (not (eq? value #f)))
    (gnc:html-markup-style-info-set-font-face-internal! record value)))

(define gnc:html-markup-style-info-font-size
  (record-accessor <html-markup-style-info> 'font-size))

(define gnc:html-markup-style-info-set-font-size-internal!
  (record-modifier <html-markup-style-info> 'font-size))

(define (gnc:html-markup-style-info-set-font-size! record value)
  (begin
    (gnc:html-markup-style-info-set-closing-font-tag!
     record (not (eq? value #f)))
    (gnc:html-markup-style-info-set-font-size-internal! record value)))

(define gnc:html-markup-style-info-font-color
  (record-accessor <html-markup-style-info> 'font-color))

(define gnc:html-markup-style-info-set-font-color-internal!
  (record-modifier <html-markup-style-info> 'font-color))

(define (gnc:html-markup-style-info-set-font-color! record value)
  (begin
    (gnc:html-markup-style-info-set-closing-font-tag!
     record (not (eq? value #f)))
    (gnc:html-markup-style-info-set-font-color-internal! record value)))

(define gnc:html-markup-style-info-closing-font-tag
  (record-accessor <html-markup-style-info> 'closing-font-tag?))
(define gnc:html-markup-style-info-set-closing-font-tag!
  (record-modifier <html-markup-style-info> 'closing-font-tag?))

(define gnc:html-markup-style-info-inheritable? 
  (record-accessor <html-markup-style-info> 'inheritable?))

(define gnc:html-markup-style-info-set-inheritable?!
  (record-modifier <html-markup-style-info> 'inheritable?))

(define (gnc:html-markup-style-info-set-attribute! info attr val)
  (hash-set! (gnc:html-markup-style-info-attributes info) attr val))

(define (gnc:html-markup-style-info-merge s1 s2) 
  (if (not (gnc:html-markup-style-info? s1))
      s2    
      (if (not (gnc:html-markup-style-info? s2))
          s1
          (let* ((tag-1  (gnc:html-markup-style-info-tag s1))
                 (face-1 (gnc:html-markup-style-info-font-face s1))
                 (size-1 (gnc:html-markup-style-info-font-size s1))
                 (color-1 (gnc:html-markup-style-info-font-color s1))
		 (closing-font-tag-1 
		  (gnc:html-markup-style-info-closing-font-tag s1)))
            (gnc:make-html-markup-style-info-internal 
             ;; tag 
             (if tag-1 tag-1 (gnc:html-markup-style-info-tag s2))
             ;; attributes: if the child is overriding the
             ;; parent tag, don't initialize the attribute table
             ;; to the parent's attributes.  Otherwise, load
             ;; parent attrs then load child attrs over them.
             (let ((ht (make-hash-table)))
               (if (not tag-1)
                   (hash-fold 
                    (lambda (k v p) (hash-set! ht k v) #f) #f 
                    (gnc:html-markup-style-info-attributes s2)))
               (hash-fold
                (lambda (k v p) (hash-set! ht k v) #f) #f 
                (gnc:html-markup-style-info-attributes s1))
               ht)
             ;; font face 
             (if face-1 face-1 (gnc:html-markup-style-info-font-face s2))
             ;; font size 
             (if size-1 size-1 (gnc:html-markup-style-info-font-size s2))
             ;; color 
             (if color-1 color-1 
                 (gnc:html-markup-style-info-font-color s2))
	     ;; closing font tag
	     (or closing-font-tag-1 
		 (gnc:html-markup-style-info-closing-font-tag s2))
             ;; inheritable (get this always from child)
             (gnc:html-markup-style-info-inheritable? s1))))))

(define (gnc:html-style-info-merge s1 s2)
  (if (or (gnc:html-markup-style-info? s1)
          (gnc:html-markup-style-info? s2))
      (gnc:html-markup-style-info-merge s1 s2)
      (if (or (gnc:html-data-style-info? s1)
              (gnc:html-data-style-info? s2))
          (gnc:html-data-style-info-merge s1 s2)
          #f)))

(define (gnc:html-data-style-info-merge s1 s2)
  (if (gnc:html-data-style-info? s1) s1 s2))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  <html-data-style-info> class 
;;
;;  literal data is rendered using the html-data-style for that type.
;;  ATM the rendering style is defined using a thunk to do the
;;  rendering and some data to pass in addition to the object to be
;;  rendered.
;;
;;  the renderer is a function of two arguments.  The first arg is the
;;  data to be rendered and the second is the 'data' specified in the
;;  style.  The return should be an HTML string.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define <html-data-style-info> 
  (make-record-type "<html-data-style-info>"
                    '(renderer data inheritable?))) 

(define gnc:html-data-style-info? 
  (record-predicate <html-data-style-info>))

(define gnc:make-html-data-style-info-internal
  (record-constructor <html-data-style-info>))

(define (gnc:make-html-data-style-info renderer data)
  (gnc:make-html-data-style-info-internal renderer data #t))

(define gnc:html-data-style-info? 
  (record-predicate <html-data-style-info>))

(define gnc:html-data-style-info-renderer 
  (record-accessor <html-data-style-info> 'renderer))

(define gnc:html-data-style-info-set-renderer!
  (record-modifier <html-data-style-info> 'renderer))

(define gnc:html-data-style-info-data 
  (record-accessor <html-data-style-info> 'data))

(define gnc:html-data-style-info-set-data!
  (record-modifier <html-data-style-info> 'data))

(define gnc:html-data-style-info-inheritable? 
  (record-accessor <html-data-style-info> 'inheritable?))

(define gnc:html-data-style-info-set-inheritable?!
  (record-modifier <html-data-style-info> 'inheritable?))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  default renderers for some data types.  
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define (gnc:default-html-string-renderer datum params)
  datum)

(define (gnc:default-html-gnc-numeric-renderer datum params)
  (xaccPrintAmount datum (gnc-default-print-info #f)))

(define (gnc:default-html-gnc-monetary-renderer datum params)
  (xaccPrintAmount                                                 
   (gnc:gnc-monetary-amount datum)                                    
   (gnc-commodity-print-info (gnc:gnc-monetary-commodity datum) #t)))

(define (gnc:default-html-number-renderer datum params)  
  (xaccPrintAmount
   (double-to-gnc-numeric datum 100 GNC-RND-ROUND)
   (gnc-default-print-info #f)))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; <html-style-table> class
;;
;; this used to just be bare hash tables stuck in the <html-object>
;; but since we now support caching and compilation I think it 
;; deserves a record structure. 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define <html-style-table>
  (make-record-type "<html-style-table>"
                    '(primary compiled inheritable)))

(define gnc:html-style-table? 
  (record-predicate <html-style-table>))

(define gnc:make-html-style-table-internal 
  (record-constructor <html-style-table>))

(define (gnc:make-html-style-table)
  (gnc:make-html-style-table-internal (make-hash-table) #f #f))

(define gnc:html-style-table-primary
  (record-accessor <html-style-table> 'primary))

(define gnc:html-style-table-compiled
  (record-accessor <html-style-table> 'compiled))

(define gnc:html-style-table-set-compiled!
  (record-modifier <html-style-table> 'compiled))

(define gnc:html-style-table-inheritable
  (record-accessor <html-style-table> 'inheritable))

(define gnc:html-style-table-set-inheritable!
  (record-modifier <html-style-table> 'inheritable))

(define (gnc:html-style-table-compiled? table)
  (if (gnc:html-style-table-compiled table)
      #t #f))

(define (gnc:html-style-table-compile table antecedents)
  ;; merge a key-value pair from an antecedent into the 
  ;; compiled table.  Only add values to the inheritable table
  ;; that are inheritable. 
  (define (key-merger key value ign)
    (let* ((compiled (gnc:html-style-table-compiled table))
           (inheritable (gnc:html-style-table-inheritable table))
           (old-val (hash-ref compiled key))
           (new-val (gnc:html-style-info-merge old-val value)))
      (hash-set! compiled key new-val)
      (if (and (gnc:html-markup-style-info? value)
               (gnc:html-markup-style-info-inheritable? value))
          (hash-set! inheritable key new-val))
      (if (and (gnc:html-data-style-info? value)
               (gnc:html-data-style-info-inheritable? value))
          (hash-set! inheritable key new-val))))
  
  ;; walk up the list of antecedents merging in style info
  (define (compile-worker table-list)
    (let ((next (car table-list)))
      (if (gnc:html-style-table-compiled? next)
          (begin
            (hash-fold key-merger #f (gnc:html-style-table-compiled next))
            #t)
          (begin 
            (hash-fold key-merger #f (gnc:html-style-table-primary next))
            (if (not (null? (cdr table-list)))
                (compile-worker (cdr table-list))
                #t)))))
  ;; make the compiled hash table 
  (gnc:html-style-table-set-compiled! table (make-hash-table))
  (gnc:html-style-table-set-inheritable! table (make-hash-table))
  
  ;; merge the contents of the primary hash into the compiled table 
  (hash-fold key-merger #f (gnc:html-style-table-primary table))
  
  ;; now merge in the antecedents 
  (if (not (null? antecedents))
      (compile-worker antecedents)))

  
(define (gnc:html-style-table-uncompile table)
  (gnc:html-style-table-set-compiled! table #f)
  (gnc:html-style-table-set-inheritable! table #f))

(define (gnc:html-style-table-fetch table antecedents markup)
  (define (get-inheritable-style ht)
    (let ((s (hash-ref ht markup)))
      (if (or (and (gnc:html-markup-style-info? s)
                   (gnc:html-markup-style-info-inheritable? s))
              (and (gnc:html-data-style-info? s)
                   (gnc:html-data-style-info-inheritable? s)))
          s #f)))
  
  (define (fetch-worker style antecedents)
    (if (null? antecedents)
        style
        (let ((parent (car antecedents)))
          (if (not parent)
              (fetch-worker style (cdr antecedents))
              (if (gnc:html-style-table-compiled? parent)
                  (gnc:html-style-info-merge 
                   style 
                   (hash-ref (gnc:html-style-table-inheritable parent) markup))
                  (fetch-worker 
                   (gnc:html-style-info-merge 
                    style (get-inheritable-style 
                           (gnc:html-style-table-primary parent)))
                   (cdr antecedents)))))))

  (if (and table (gnc:html-style-table-compiled? table))
      (hash-ref (gnc:html-style-table-compiled table) markup)
      (fetch-worker 
       (if table 
           (hash-ref (gnc:html-style-table-primary table) markup)
           #f)
       antecedents)))

(define (gnc:html-style-table-set! table markup style-info)
  (hash-set! (gnc:html-style-table-primary table) markup style-info))