clerk icon indicating copy to clipboard operation
clerk copied to clipboard

Rendering numbers and strings

Open genmeblog opened this issue 3 years ago • 2 comments

Two minor issues.

  • floating point number with fractional part = 0 is rendered as an integer
  • strings are double quoted (ok) but in tables are not
[1.0 2.0 3.0 4.5 5.0]
;; [1 2 3 4.5 5]
;; should be [1.0 2.0 3.0 4.5 5.0]

(map str [1.0 2.0 3.0 4.5 5.0])
;; ("1.0" "2.0" "3.0" "4.5" "5.0")

(clerk/table
 [[[1.0 2.0 3.0 4.5 5.0]]
  [(map str [1.0 2.0 3.0 4.5 5.0])]])
;; [1 2 3 4.5 5]
;; (1.0 2.0 3.0 4.5 5.0) ;; should be ("1.0" "2.0" "3.0" "4.5" "5.0")

genmeblog avatar Mar 16 '22 12:03 genmeblog

Thanks for the report. The number is probably due to javascript representation of numbers and something we'll look into fixing.

That strings aren't quoted in tables is intentional as it's how spreadsheet software will display strings. You can change it by removing the viewer from !viewers: https://github.com/nextjournal/clerk/blob/8a44eba2a2fd99e6e9350cfafddf6bdea1c07bd3/src/nextjournal/clerk/viewer.cljc#L243

mk avatar Mar 16 '22 12:03 mk

Ok, thanks.

genmeblog avatar Mar 16 '22 15:03 genmeblog