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)
|
(define (query owner account-list start-date end-date)
|
||||||
(let* ((q (qof-query-create-for-splits))
|
(let* ((q (qof-query-create-for-splits))
|
||||||
(guid (and owner
|
(guid (and owner
|
||||||
@@ -232,8 +221,7 @@
|
|||||||
'attribute (list "cellspacing" 0)
|
'attribute (list "cellspacing" 0)
|
||||||
'attribute (list "cellpadding" 0))
|
'attribute (list "cellpadding" 0))
|
||||||
(if name (gnc:html-table-append-row! table (list name)))
|
(if name (gnc:html-table-append-row! table (list name)))
|
||||||
(if addy (gnc:html-table-append-row!
|
(if addy (gnc:html-table-append-row! table (gnc:multiline-to-html-text addy)))
|
||||||
table (list (string-expand addy #\newline "<br/>"))))
|
|
||||||
(gnc:html-table-append-row!
|
(gnc:html-table-append-row!
|
||||||
table (list (gnc-print-time64 (gnc:get-today) date-format)))
|
table (list (gnc-print-time64 (gnc:get-today) date-format)))
|
||||||
(let ((table-outer (gnc:make-html-table)))
|
(let ((table-outer (gnc:make-html-table)))
|
||||||
|
|||||||
@@ -178,15 +178,7 @@
|
|||||||
keylist))
|
keylist))
|
||||||
|
|
||||||
(define (multiline-to-html-text str)
|
(define (multiline-to-html-text str)
|
||||||
;; simple function - splits string containing #\newline into
|
(gnc:multiline-to-html-text str))
|
||||||
;; 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)))))
|
|
||||||
|
|
||||||
(define (options-generator variant)
|
(define (options-generator variant)
|
||||||
|
|
||||||
|
|||||||
@@ -416,24 +416,6 @@
|
|||||||
(options-generator (list ACCT-TYPE-PAYABLE) GNC-OWNER-EMPLOYEE
|
(options-generator (list ACCT-TYPE-PAYABLE) GNC-OWNER-EMPLOYEE
|
||||||
(_ "Expense Report") #t))
|
(_ "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)
|
(define (setup-query q owner account end-date)
|
||||||
(let* ((guid (gncOwnerReturnGUID owner)))
|
(let* ((guid (gncOwnerReturnGUID owner)))
|
||||||
|
|
||||||
@@ -464,13 +446,15 @@
|
|||||||
'attribute (list "border" 0)
|
'attribute (list "border" 0)
|
||||||
'attribute (list "cellspacing" 0)
|
'attribute (list "cellspacing" 0)
|
||||||
'attribute (list "cellpadding" 0))
|
'attribute (list "cellpadding" 0))
|
||||||
|
|
||||||
(gnc:html-table-append-row!
|
(gnc:html-table-append-row!
|
||||||
table
|
table
|
||||||
(list
|
(list (gnc:multiline-to-html-text
|
||||||
(string-expand (gnc:owner-get-name-and-address-dep owner) #\newline "<br/>")))
|
(gnc:owner-get-name-and-address-dep owner))))
|
||||||
|
|
||||||
(gnc:html-table-append-row!
|
(gnc:html-table-append-row!
|
||||||
table
|
table (gnc:make-html-text (gnc:html-markup-br)))
|
||||||
(list "<br/>"))
|
|
||||||
(gnc:html-table-set-last-row-style!
|
(gnc:html-table-set-last-row-style!
|
||||||
table "td"
|
table "td"
|
||||||
'attribute (list "valign" "top"))
|
'attribute (list "valign" "top"))
|
||||||
@@ -507,10 +491,10 @@
|
|||||||
'attribute (list "cellspacing" 0)
|
'attribute (list "cellspacing" 0)
|
||||||
'attribute (list "cellpadding" 0))
|
'attribute (list "cellpadding" 0))
|
||||||
|
|
||||||
(gnc:html-table-append-row! table (list (if name name "")))
|
(gnc:html-table-append-row! table (list (or name "")))
|
||||||
(gnc:html-table-append-row! table (list (string-expand
|
|
||||||
(if addy addy "")
|
(gnc:html-table-append-row! table (list (gnc:multiline-to-html-text (or addy ""))))
|
||||||
#\newline "<br/>")))
|
|
||||||
(gnc:html-table-append-row!
|
(gnc:html-table-append-row!
|
||||||
table (list (gnc-print-time64 (current-time) date-format)))
|
table (list (gnc-print-time64 (current-time) date-format)))
|
||||||
table))
|
table))
|
||||||
|
|||||||
@@ -627,24 +627,6 @@
|
|||||||
(define (employee-options-generator)
|
(define (employee-options-generator)
|
||||||
(options-generator (list ACCT-TYPE-PAYABLE) GNC-OWNER-EMPLOYEE #t))
|
(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)
|
(define (setup-query q owner account end-date)
|
||||||
(let* ((guid (gncOwnerReturnGUID (gncOwnerGetEndOwner owner))))
|
(let* ((guid (gncOwnerReturnGUID (gncOwnerGetEndOwner owner))))
|
||||||
|
|
||||||
@@ -675,16 +657,17 @@
|
|||||||
'attribute (list "border" 0)
|
'attribute (list "border" 0)
|
||||||
'attribute (list "cellspacing" 0)
|
'attribute (list "cellspacing" 0)
|
||||||
'attribute (list "cellpadding" 0))
|
'attribute (list "cellpadding" 0))
|
||||||
|
|
||||||
(gnc:html-table-append-row!
|
(gnc:html-table-append-row!
|
||||||
table
|
table (gnc:multiline-to-html-text (gnc:owner-get-name-and-address-dep owner)))
|
||||||
(list
|
|
||||||
(string-expand (gnc:owner-get-name-and-address-dep owner) #\newline "<br/>")))
|
|
||||||
(gnc:html-table-append-row!
|
(gnc:html-table-append-row!
|
||||||
table
|
table (gnc:make-html-text (gnc:html-markup-br)))
|
||||||
(list "<br/>"))
|
|
||||||
(gnc:html-table-set-last-row-style!
|
(gnc:html-table-set-last-row-style!
|
||||||
table "td"
|
table "td"
|
||||||
'attribute (list "valign" "top"))
|
'attribute (list "valign" "top"))
|
||||||
|
|
||||||
table))
|
table))
|
||||||
|
|
||||||
(define (make-date-row! table label date)
|
(define (make-date-row! table label date)
|
||||||
@@ -718,12 +701,14 @@
|
|||||||
'attribute (list "cellspacing" 0)
|
'attribute (list "cellspacing" 0)
|
||||||
'attribute (list "cellpadding" 0))
|
'attribute (list "cellpadding" 0))
|
||||||
|
|
||||||
(gnc:html-table-append-row! table (list (if name name "")))
|
(gnc:html-table-append-row! table (list (or name "")))
|
||||||
(gnc:html-table-append-row! table (list (string-expand
|
|
||||||
(if addy addy "")
|
(gnc:html-table-append-row!
|
||||||
#\newline "<br/>")))
|
table (list (gnc:multiline-to-html-text (or addy ""))))
|
||||||
|
|
||||||
(gnc:html-table-append-row!
|
(gnc:html-table-append-row!
|
||||||
table (list (gnc-print-time64 (gnc:get-today) date-format)))
|
table (list (gnc-print-time64 (gnc:get-today) date-format)))
|
||||||
|
|
||||||
table))
|
table))
|
||||||
|
|
||||||
(define (make-break! document)
|
(define (make-break! document)
|
||||||
|
|||||||
Reference in New Issue
Block a user