[html-text][API] gnc:html-markup-ol, gnc:multiline-to-html-text

* (gnc:html-markup-ol lst)

  creates an ordered list

* gnc:multiline-to-html-text: creates html-text with <br/> elements

  "line1\nline2\nline3" ->
  (gnc:make-html-text "line1" (gnc:html-markup-br)
                      "line2" (gnc:html-markup-br)
                      "line3")
This commit is contained in:
Christopher Lam 2019-12-01 22:17:19 +08:00
parent a52d60f48e
commit 4aa17ef65b
3 changed files with 15 additions and 0 deletions

View File

@ -182,6 +182,9 @@
(gnc:html-markup "li" obj))
items)))
(define (gnc:html-markup-ol lst)
(apply gnc:html-markup "ol"
(map (lambda (elt) (gnc:html-markup "li" elt)) lst)))
(define (gnc:html-markup-anchor href . rest)
(apply gnc:html-markup/attr

View File

@ -666,6 +666,7 @@
(export gnc:html-markup-h3)
(export gnc:html-markup-br)
(export gnc:html-markup-hr)
(export gnc:html-markup-ol)
(export gnc:html-markup-ul)
(export gnc:html-markup-anchor)
(export gnc:html-markup-img)
@ -744,6 +745,7 @@
(export gnc:get-assoc-account-balances)
(export gnc:select-assoc-account-balance)
(export gnc:get-assoc-account-balances-total)
(export gnc:multiline-to-html-text)
(export make-file-url)
(export gnc:strify)
(export gnc:pk)

View File

@ -1109,6 +1109,16 @@ flawed. see report-utilities.scm. please update reports.")
account-balances)
total))
(define (gnc: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)))))
;; ***************************************************************************
;; Business Functions