mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[reports] avoid "<br/>" literal: use gnc:multiline-to-html-text
This commit is contained in:
@@ -179,17 +179,6 @@
|
||||
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(define (string-expand string character replace-string)
|
||||
(with-output-to-string
|
||||
(lambda ()
|
||||
(string-for-each
|
||||
(lambda (c)
|
||||
(display
|
||||
(if (char=? c character)
|
||||
replace-string
|
||||
c)))
|
||||
string))))
|
||||
|
||||
(define (query owner account-list start-date end-date)
|
||||
(let* ((q (qof-query-create-for-splits))
|
||||
(guid (and owner
|
||||
@@ -232,8 +221,7 @@
|
||||
'attribute (list "cellspacing" 0)
|
||||
'attribute (list "cellpadding" 0))
|
||||
(if name (gnc:html-table-append-row! table (list name)))
|
||||
(if addy (gnc:html-table-append-row!
|
||||
table (list (string-expand addy #\newline "<br/>"))))
|
||||
(if addy (gnc:html-table-append-row! table (gnc:multiline-to-html-text addy)))
|
||||
(gnc:html-table-append-row!
|
||||
table (list (gnc-print-time64 (gnc:get-today) date-format)))
|
||||
(let ((table-outer (gnc:make-html-table)))
|
||||
|
||||
@@ -178,15 +178,7 @@
|
||||
keylist))
|
||||
|
||||
(define (multiline-to-html-text str)
|
||||
;; simple function - splits string containing #\newline into
|
||||
;; substrings, and convert to a gnc:make-html-text construct which
|
||||
;; adds gnc:html-markup-br after each substring.
|
||||
(let loop ((list-of-substrings (string-split str #\newline))
|
||||
(result '()))
|
||||
(if (null? list-of-substrings)
|
||||
(apply gnc:make-html-text (if (null? result) '() (reverse (cdr result))))
|
||||
(loop (cdr list-of-substrings)
|
||||
(cons* (gnc:html-markup-br) (car list-of-substrings) result)))))
|
||||
(gnc:multiline-to-html-text str))
|
||||
|
||||
(define (options-generator variant)
|
||||
|
||||
|
||||
@@ -416,24 +416,6 @@
|
||||
(options-generator (list ACCT-TYPE-PAYABLE) GNC-OWNER-EMPLOYEE
|
||||
(_ "Expense Report") #t))
|
||||
|
||||
(define (string-expand string character replace-string)
|
||||
(define (car-line chars)
|
||||
(take-while (lambda (c) (not (eqv? c character))) chars))
|
||||
(define (cdr-line chars)
|
||||
(let ((rest (drop-while (lambda (c) (not (eqv? c character))) chars)))
|
||||
(if (null? rest)
|
||||
'()
|
||||
(cdr rest))))
|
||||
(define (line-helper chars)
|
||||
(if (null? chars)
|
||||
""
|
||||
(let ((first (car-line chars))
|
||||
(rest (cdr-line chars)))
|
||||
(string-append (list->string first)
|
||||
(if (null? rest) "" replace-string)
|
||||
(line-helper rest)))))
|
||||
(line-helper (string->list string)))
|
||||
|
||||
(define (setup-query q owner account end-date)
|
||||
(let* ((guid (gncOwnerReturnGUID owner)))
|
||||
|
||||
@@ -464,13 +446,15 @@
|
||||
'attribute (list "border" 0)
|
||||
'attribute (list "cellspacing" 0)
|
||||
'attribute (list "cellpadding" 0))
|
||||
|
||||
(gnc:html-table-append-row!
|
||||
table
|
||||
(list
|
||||
(string-expand (gnc:owner-get-name-and-address-dep owner) #\newline "<br/>")))
|
||||
(list (gnc:multiline-to-html-text
|
||||
(gnc:owner-get-name-and-address-dep owner))))
|
||||
|
||||
(gnc:html-table-append-row!
|
||||
table
|
||||
(list "<br/>"))
|
||||
table (gnc:make-html-text (gnc:html-markup-br)))
|
||||
|
||||
(gnc:html-table-set-last-row-style!
|
||||
table "td"
|
||||
'attribute (list "valign" "top"))
|
||||
@@ -507,10 +491,10 @@
|
||||
'attribute (list "cellspacing" 0)
|
||||
'attribute (list "cellpadding" 0))
|
||||
|
||||
(gnc:html-table-append-row! table (list (if name name "")))
|
||||
(gnc:html-table-append-row! table (list (string-expand
|
||||
(if addy addy "")
|
||||
#\newline "<br/>")))
|
||||
(gnc:html-table-append-row! table (list (or name "")))
|
||||
|
||||
(gnc:html-table-append-row! table (list (gnc:multiline-to-html-text (or addy ""))))
|
||||
|
||||
(gnc:html-table-append-row!
|
||||
table (list (gnc-print-time64 (current-time) date-format)))
|
||||
table))
|
||||
|
||||
@@ -627,24 +627,6 @@
|
||||
(define (employee-options-generator)
|
||||
(options-generator (list ACCT-TYPE-PAYABLE) GNC-OWNER-EMPLOYEE #t))
|
||||
|
||||
(define (string-expand string character replace-string)
|
||||
(define (car-line chars)
|
||||
(take-while (lambda (c) (not (eqv? c character))) chars))
|
||||
(define (cdr-line chars)
|
||||
(let ((rest (drop-while (lambda (c) (not (eqv? c character))) chars)))
|
||||
(if (null? rest)
|
||||
'()
|
||||
(cdr rest))))
|
||||
(define (line-helper chars)
|
||||
(if (null? chars)
|
||||
""
|
||||
(let ((first (car-line chars))
|
||||
(rest (cdr-line chars)))
|
||||
(string-append (list->string first)
|
||||
(if (null? rest) "" replace-string)
|
||||
(line-helper rest)))))
|
||||
(line-helper (string->list string)))
|
||||
|
||||
(define (setup-query q owner account end-date)
|
||||
(let* ((guid (gncOwnerReturnGUID (gncOwnerGetEndOwner owner))))
|
||||
|
||||
@@ -675,16 +657,17 @@
|
||||
'attribute (list "border" 0)
|
||||
'attribute (list "cellspacing" 0)
|
||||
'attribute (list "cellpadding" 0))
|
||||
|
||||
(gnc:html-table-append-row!
|
||||
table
|
||||
(list
|
||||
(string-expand (gnc:owner-get-name-and-address-dep owner) #\newline "<br/>")))
|
||||
table (gnc:multiline-to-html-text (gnc:owner-get-name-and-address-dep owner)))
|
||||
|
||||
(gnc:html-table-append-row!
|
||||
table
|
||||
(list "<br/>"))
|
||||
table (gnc:make-html-text (gnc:html-markup-br)))
|
||||
|
||||
(gnc:html-table-set-last-row-style!
|
||||
table "td"
|
||||
'attribute (list "valign" "top"))
|
||||
|
||||
table))
|
||||
|
||||
(define (make-date-row! table label date)
|
||||
@@ -718,12 +701,14 @@
|
||||
'attribute (list "cellspacing" 0)
|
||||
'attribute (list "cellpadding" 0))
|
||||
|
||||
(gnc:html-table-append-row! table (list (if name name "")))
|
||||
(gnc:html-table-append-row! table (list (string-expand
|
||||
(if addy addy "")
|
||||
#\newline "<br/>")))
|
||||
(gnc:html-table-append-row! table (list (or name "")))
|
||||
|
||||
(gnc:html-table-append-row!
|
||||
table (list (gnc:multiline-to-html-text (or addy ""))))
|
||||
|
||||
(gnc:html-table-append-row!
|
||||
table (list (gnc-print-time64 (gnc:get-today) date-format)))
|
||||
|
||||
table))
|
||||
|
||||
(define (make-break! document)
|
||||
|
||||
Reference in New Issue
Block a user