# \[ANN\] PrettyTables.jl v2.3.0 - Markdown back end

**URL:** https://discourse.julialang.org/t/ann-prettytables-jl-v2-3-0-markdown-back-end/106168
**Category:** Package Announcements
**Created:** [November 14, 2023, 12:27am UTC](https://discourse.julialang.org/t/ann-prettytables-jl-v2-3-0-markdown-back-end/106168 "2023-11-14T00:27:23Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)
#### Post date: [November 14, 2023, 12:27am UTC](https://discourse.julialang.org/t/ann-prettytables-jl-v2-3-0-markdown-back-end/106168/1 "2023-11-14T00:27:23Z")

</div>

Hi everyone!

I was a little off from the community due to some problems, but I’m back now. 🙂

I want to announce that I just tagged PrettyTables.jl v2.3.0. We have some important internal improvements (like using ~~PackageCompiler.jl~~ PrecomipleTools.jl to generate precompilation statements), but the significant feature here is the new true Markdown back end.

If you pass `backend = Val(:markdown)`, you will see:

```julia
julia> pretty_table(rand(4, 4), backend = Val(:markdown))
| **Col. 1** | **Col. 2** | **Col. 3** | **Col. 4** |
|-----------:|-----------:|-----------:|-----------:|
| 0.91437 | 0.166273 | 0.0286585 | 0.51545 |
| 0.869749 | 0.332251 | 0.598352 | 0.815126 |
| 0.959903 | 0.910812 | 0.773085 | 0.860781 |
| 0.0229836 | 0.583163 | 0.473758 | 0.334024 |

```

Differently from what we had in the past (using text back end), if we change the column alignment, the text itself does not change, but the alignment row is update accordingly:

```julia
julia> pretty_table(rand(4, 4), backend = Val(:markdown), alignment = [:l, :c, :r, :r])
| **Col. 1** | **Col. 2** | **Col. 3** | **Col. 4** |
|:-----------|:----------:|-----------:|-----------:|
| 0.593286 | 0.547841 | 0.255428 | 0.0311389 |
| 0.662025 | 0.333026 | 0.229236 | 0.852613 |
| 0.357072 | 0.86252 | 0.175641 | 0.376265 |
| 0.880573 | 0.94005 | 0.279839 | 0.998748 |

```

The highlighters in the Markdown back end receives an object of type `MarkdownDecoration` that can modify the text in the cell by setting it to be **bold** , _italic_, ~strikethrough~, or `code`. For example:

```julia
julia> pretty_table(
           rand(4, 4),
           backend = Val(:markdown),
           highlighters = (
               hl_col(1, MarkdownDecoration(bold = true)),
               hl_col(2, MarkdownDecoration(italic = true)),
               hl_col(3, MarkdownDecoration(strikethrough = true)),
               hl_col(4, MarkdownDecoration(code = true))
           )
       )
| **Col. 1** | **Col. 2** | **Col. 3** | **Col. 4** |
|--------------:|-----------:|-----------:|-----------:|
| **0.869034** | _0.861814_ | ~0.335917~ | `0.637624` |
| **0.986734** | _0.234084_ | ~0.507542~ | `0.113188` |
| **0.0876319** | _0.881392_ | ~0.302185~ | `0.656289` |
| **0.829593** | _0.478708_ | ~0.876485~ | `0.266334` |

```

Since it will work with any Tables.jl object, we can now print a `DataFrame` to Markdown using:

```julia
julia> df = DataFrame(a=["a", "None", "b", "None"], b=1:4,
                      c=["None", "j", "k", "h"], d=["x", "y", "None", "z"])
4×4 DataFrame
 Row │ a b c d      
     │ String Int64 String String 
─────┼───────────────────────────────
   1 │ a 1 None x
   2 │ None 2 j y
   3 │ b 3 k None
   4 │ None 4 h z

julia> pretty_table(df, backend = Val(:markdown))
| **a** <br>`String` | **b** <br>`Int64` | **c** <br>`String` | **d** <br>`String` |
|------------------:|-----------------:|------------------:|------------------:|
| a | 1 | None | x |
| None | 2 | j | y |
| b | 3 | k | None |
| None | 4 | h | z |

```

which is rendered in [https://markdownlivepreview.com](https://markdownlivepreview.com) as:

 ![Captura de Tela 2023-11-13 às 21.20.15](https://global.discourse-cdn.com/julialang/original/3X/6/8/68f6ce68b179e47a861e6f2ec9b2bd3f947644d4.png)

The Markdown output **is not** limited by the display size as in text back end. However, we can set `max_num_of_rows` and `max_num_of_columns` to crop the output for big tables:

```julia
julia> pretty_table(
           rand(1000, 1000),
           backend = Val(:markdown),
           max_num_of_rows = 4,
           max_num_of_columns = 4,
           show_omitted_cell_summary = true
       )
| **Col. 1** | **Col. 2** | **Col. 3** | **Col. 4** | ⋯ |
|-----------:|-----------:|-----------:|-----------:|:-:|
| 0.322182 | 0.532873 | 0.586433 | 0.0899228 | ⋯ |
| 0.31999 | 0.392158 | 0.351315 | 0.696006 | ⋯ |
| 0.0767427 | 0.885363 | 0.454803 | 0.627742 | ⋯ |
| 0.143568 | 0.35654 | 0.410591 | 0.347192 | ⋯ |
| ⋮ | ⋮ | ⋮ | ⋮ | ⋱ |

_996 columns and 996 rows omitted_

```

which is renderer as:

 ![Captura de Tela 2023-11-13 às 21.23.25](https://global.discourse-cdn.com/julialang/original/3X/c/b/cb3650b27e0caad083bc19891631cd1c4aae9469.png)

---

<div class="post-metadata">

### Author: ![alfaromartino](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alfaromartino/32/52986_2.png) [@alfaromartino](https://discourse.julialang.org/u/alfaromartino)
#### Post date: [November 14, 2023, 12:34am UTC](https://discourse.julialang.org/t/ann-prettytables-jl-v2-3-0-markdown-back-end/106168/2 "2023-11-14T00:34:12Z")

</div>

Thanks for your hard work! PrettyTables is a extremely helpful package.

---

<div class="post-metadata">

### Author: ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)
#### Post date: [November 14, 2023, 8:37am UTC](https://discourse.julialang.org/t/ann-prettytables-jl-v2-3-0-markdown-back-end/106168/3 "2023-11-14T08:37:31Z")

</div>

This is awesome! Thank you!

---

<div class="post-metadata">

### Author: ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)
#### Post date: [November 15, 2023, 9:28pm UTC](https://discourse.julialang.org/t/ann-prettytables-jl-v2-3-0-markdown-back-end/106168/4 "2023-11-15T21:28:29Z")

</div>

> [@Ronis\_BR](#):
>
> PackageCompiler.jl

Actually I meant PrecompileTools.jl here 😃 Thanks @Palli

---

<div class="post-metadata">

### Author: ![neophytedave](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/neophytedave/32/202273_2.png) [@neophytedave](https://discourse.julialang.org/u/neophytedave)
#### Post date: [November 15, 2023, 9:48pm UTC](https://discourse.julialang.org/t/ann-prettytables-jl-v2-3-0-markdown-back-end/106168/5 "2023-11-15T21:48:45Z")

</div>

How does Pretty Tables compare with table management in EMACS org mode?

---

<div class="post-metadata">

### Author: ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)
#### Post date: [November 16, 2023, 12:10am UTC](https://discourse.julialang.org/t/ann-prettytables-jl-v2-3-0-markdown-back-end/106168/6 "2023-11-16T00:10:16Z")

</div>

PrettyTables.jl only prints tables in different back ends (text, latex, html, and now markdown). It also has the possibility to format cells and apply some decorations. It does not have all the features we see in org-mode, like cell formulas etc. However, this kind of processing can be easily done using DataFrames, which uses PrettyTables.jl to display the data.
