Skip to content

Commit

Permalink
πŸ› Do not remove quotes if cell is AbstractString
Browse files Browse the repository at this point in the history
  • Loading branch information
ronisbr committed Sep 30, 2020
1 parent 2c260d0 commit 6d6c6e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/backends/text/cell_parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ end
renderer::Union{Val{:print}, Val{:show}} = Val(:print),
kwargs...)

isstring = cell_data_type <: String
isstring = cell_data_type <: AbstractString

if cell_first_line_only
cell_vstr = [first(_str_line_breaks(cell,
Expand Down
14 changes: 8 additions & 6 deletions test/text_backend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2392,7 +2392,7 @@ end
# Test the behavior if a formatter returns a string but the original data is
# not a string. In this case, the renderer `show` must not add surrounding
# quotes.
matrix = ['1' "2" 3]
matrix = ['1' "2" 3 s"123"]

f = (v,i,j)->begin
if j == 1
Expand All @@ -2401,15 +2401,17 @@ end
return "😁😁"
elseif j == 3
return 'a'
else
return v
end
end

expected = """
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Col. 1 β”‚ Col. 2 β”‚ Col. 3 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ πŸ˜€πŸ˜€πŸ˜€ β”‚ "😁😁" β”‚ 'a' β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Col. 1 β”‚ Col. 2 β”‚ Col. 3 β”‚ Col. 4 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ πŸ˜€πŸ˜€πŸ˜€ β”‚ "😁😁" β”‚ 'a' β”‚ s"123" β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”˜
"""

result = pretty_table(String, matrix,
Expand Down

0 comments on commit 6d6c6e1

Please sign in to comment.