[ANN] PrettyTables v3.0.0

Thank you @Ronis_BR, super helpful as usual :heart_hands: Please let me know when the bug is fixed, and I will update the PR accordingly to make styled strings work on all backends.

Make it the default if possible. That way we can rely on the same call for :text and :html.

1 Like

Unfortunately we cannot do this because Julia Base use print by default to convert objects :frowning:

Would be possible, from your side, to add renderer = :show if the output is HTML?

Another possibility (but it will have some implications) is to always use show if a cell is a StyledString.

Maybe I am misunderstanding something. You mean add the option in the test with sprint?

My suggestion above was about making the behavior consistent across platforms. For example, I would like to test the new release on Quarto and Jupyter. I am assuming that the default with print is enough to make things “work as expected”?

If I show a table on the REPL, I get colors. I would like to get the same colors in HTML on Quarto and Jupyter. Please advise on how to achieve that.

No! I mean, pass the option renderer = :show to the function pretty_table.

Got it. In that case, the option affects the :text output in undesired ways. I will add this option for the :html output only.

1 Like

Thanks! Because the other way would require to add StyledStrings.jl as dependency to PrettyTables and always render it using show. I am not sure the side effects it will have.

2 Likes

From what I am seeing, the option removes the colors in the HTML output. I will go ahead and merge the PR to propagate the new release. This renderer=:show is the only incosistency between :text and :html so far.

1 Like

Yes! Because the bug I mentioned. I just fixed it in master. Can you test from master? In this case, using renderer = :show and StyledStrings.jl will lead to correct colors in HTML backend.

In text backend, any renderer will work correctly.

1 Like

Gave it a try with the version on master and the color output seems correct in HTML. I only printed it to the REPL with show and MIME"text/html" though.

Updated the PR with a future 3.0.2 version for PrettyTables.jl. Will rerun tests when the patch becomes available.

1 Like

Hi @juliohm !

Version 3.0.2 should be out very soon (waiting for the auto merging of the PR).

1 Like

@Ronis_BR I’ve rerun the tests, and the HTML one is failing on Windows and Ubuntu with Julia LTS. Any idea of what might be happening?

Error message:

show: Test Failed at /home/runner/work/GeoTables.jl/GeoTables.jl/test/shows.jl:144
  Expression: sprint(show, MIME("text/html"), gtb) == "<table>\n  <thead>\n    <tr class = \"title\">\n      <td colspan = \"4\" style = \"text-align: center; font-size: x-large; font-weight: bold;\">9×4 GeoTable over 9 PointSet</td>\n    </tr>\n    <tr class = \"columnLabelRow\">\n      <th style = \"text-align: center; font-weight: bold;\"><span style=\"font-weight: 700; color: #803d9b\">a</span></th>\n      <th style = \"text-align: center; font-weight: bold;\"><span style=\"font-weight: 700; color: #803d9b\">b</span></th>\n      <th style = \"text-align: center; font-weight: bold;\"><span style=\"font-weight: 700; color: #803d9b\">c</span></th>\n      <th style = \"text-align: center; font-weight: bold;\"><span style=\"font-weight: 700; color: #0097a7\">geometry</span></th>\n    </tr>\n    <tr class = \"columnLabelRow\">\n      <th style = \"text-align: center;\">Categorical</th>\n      <th style = \"text-align: center;\">Continuous</th>\n      <th style = \"text-align: center;\">Categorical</th>\n      <th style = \"text-align: center;\">Point</th>\n    </tr>\n    <tr class = \"columnLabelRow\">\n      <th style = \"text-align: center;\">[NoUnits]</th>\n      <th style = \"text-align: center;\">[NoUnits]</th>\n      <th style = \"text-align: center;\">[NoUnits]</th>\n      <th style = \"text-align: center;\">🖈 Cartesian{NoDatum}</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">0</td>\n      <td style = \"text-align: center;\">2.34</td>\n      <td style = \"text-align: center;\">txt1</td>\n      <td style = \"text-align: center;\">(x: 1.0 m, y: 1.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">6</td>\n      <td style = \"text-align: center;\">7.5</td>\n      <td style = \"text-align: center;\">txt2</td>\n      <td style = \"text-align: center;\">(x: 2.0 m, y: 2.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">6</td>\n      <td style = \"text-align: center;\">0.06</td>\n      <td style = \"text-align: center;\">txt3</td>\n      <td style = \"text-align: center;\">(x: 3.0 m, y: 3.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">3</td>\n      <td style = \"text-align: center;\">1.29</td>\n      <td style = \"text-align: center;\">txt4</td>\n      <td style = \"text-align: center;\">(x: 4.0 m, y: 4.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">9</td>\n      <td style = \"text-align: center;\">3.64</td>\n      <td style = \"text-align: center;\">txt5</td>\n      <td style = \"text-align: center;\">(x: 5.0 m, y: 5.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">5</td>\n      <td style = \"text-align: center;\">8.05</td>\n      <td style = \"text-align: center;\">txt6</td>\n      <td style = \"text-align: center;\">(x: 6.0 m, y: 6.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">2</td>\n      <td style = \"text-align: center;\">0.11</td>\n      <td style = \"text-align: center;\">txt7</td>\n      <td style = \"text-align: center;\">(x: 7.0 m, y: 7.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">2</td>\n      <td style = \"text-align: center;\">0.64</td>\n      <td style = \"text-align: center;\">txt8</td>\n      <td style = \"text-align: center;\">(x: 8.0 m, y: 8.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">8</td>\n      <td style = \"text-align: center;\">8.46</td>\n      <td style = \"text-align: center;\">txt9</td>\n      <td style = \"text-align: center;\">(x: 9.0 m, y: 9.0 m)</td>\n    </tr>\n  </tbody>\n</table>"
   Evaluated: "<table>\n  <thead>\n    <tr class = \"title\">\n      <td colspan = \"4\" style = \"text-align: center; font-size: x-large; font-weight: bold;\">9×4 GeoTable over 9 PointSet</td>\n    </tr>\n    <tr class = \"columnLabelRow\">\n      <th style = \"text-align: center; font-weight: bold;\"><pre><span style=\"font-weight: 700;color: #803d9b;\">a</span></pre></th>\n      <th style = \"text-align: center; font-weight: bold;\"><pre><span style=\"font-weight: 700;color: #803d9b;\">b</span></pre></th>\n      <th style = \"text-align: center; font-weight: bold;\"><pre><span style=\"font-weight: 700;color: #803d9b;\">c</span></pre></th>\n      <th style = \"text-align: center; font-weight: bold;\"><pre><span style=\"font-weight: 700;color: #0097a7;\">geometry</span></pre></th>\n    </tr>\n    <tr class = \"columnLabelRow\">\n      <th style = \"text-align: center;\">Categorical</th>\n      <th style = \"text-align: center;\">Continuous</th>\n      <th style = \"text-align: center;\">Categorical</th>\n      <th style = \"text-align: center;\">Point</th>\n    </tr>\n    <tr class = \"columnLabelRow\">\n      <th style = \"text-align: center;\">[NoUnits]</th>\n      <th style = \"text-align: center;\">[NoUnits]</th>\n      <th style = \"text-align: center;\">[NoUnits]</th>\n      <th style = \"text-align: center;\">🖈 Cartesian{NoDatum}</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">0</td>\n      <td style = \"text-align: center;\">2.34</td>\n      <td style = \"text-align: center;\">txt1</td>\n      <td style = \"text-align: center;\">(x: 1.0 m, y: 1.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">6</td>\n      <td style = \"text-align: center;\">7.5</td>\n      <td style = \"text-align: center;\">txt2</td>\n      <td style = \"text-align: center;\">(x: 2.0 m, y: 2.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">6</td>\n      <td style = \"text-align: center;\">0.06</td>\n      <td style = \"text-align: center;\">txt3</td>\n      <td style = \"text-align: center;\">(x: 3.0 m, y: 3.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">3</td>\n      <td style = \"text-align: center;\">1.29</td>\n      <td style = \"text-align: center;\">txt4</td>\n      <td style = \"text-align: center;\">(x: 4.0 m, y: 4.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">9</td>\n      <td style = \"text-align: center;\">3.64</td>\n      <td style = \"text-align: center;\">txt5</td>\n      <td style = \"text-align: center;\">(x: 5.0 m, y: 5.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">5</td>\n      <td style = \"text-align: center;\">8.05</td>\n      <td style = \"text-align: center;\">txt6</td>\n      <td style = \"text-align: center;\">(x: 6.0 m, y: 6.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">2</td>\n      <td style = \"text-align: center;\">0.11</td>\n      <td style = \"text-align: center;\">txt7</td>\n      <td style = \"text-align: center;\">(x: 7.0 m, y: 7.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">2</td>\n      <td style = \"text-align: center;\">0.64</td>\n      <td style = \"text-align: center;\">txt8</td>\n      <td style = \"text-align: center;\">(x: 8.0 m, y: 8.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">8</td>\n      <td style = \"text-align: center;\">8.46</td>\n      <td style = \"text-align: center;\">txt9</td>\n      <td style = \"text-align: center;\">(x: 9.0 m, y: 9.0 m)</td>\n    </tr>\n  </tbody>\n</table>" == "<table>\n  <thead>\n    <tr class = \"title\">\n      <td colspan = \"4\" style = \"text-align: center; font-size: x-large; font-weight: bold;\">9×4 GeoTable over 9 PointSet</td>\n    </tr>\n    <tr class = \"columnLabelRow\">\n      <th style = \"text-align: center; font-weight: bold;\"><span style=\"font-weight: 700; color: #803d9b\">a</span></th>\n      <th style = \"text-align: center; font-weight: bold;\"><span style=\"font-weight: 700; color: #803d9b\">b</span></th>\n      <th style = \"text-align: center; font-weight: bold;\"><span style=\"font-weight: 700; color: #803d9b\">c</span></th>\n      <th style = \"text-align: center; font-weight: bold;\"><span style=\"font-weight: 700; color: #0097a7\">geometry</span></th>\n    </tr>\n    <tr class = \"columnLabelRow\">\n      <th style = \"text-align: center;\">Categorical</th>\n      <th style = \"text-align: center;\">Continuous</th>\n      <th style = \"text-align: center;\">Categorical</th>\n      <th style = \"text-align: center;\">Point</th>\n    </tr>\n    <tr class = \"columnLabelRow\">\n      <th style = \"text-align: center;\">[NoUnits]</th>\n      <th style = \"text-align: center;\">[NoUnits]</th>\n      <th style = \"text-align: center;\">[NoUnits]</th>\n      <th style = \"text-align: center;\">🖈 Cartesian{NoDatum}</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">0</td>\n      <td style = \"text-align: center;\">2.34</td>\n      <td style = \"text-align: center;\">txt1</td>\n      <td style = \"text-align: center;\">(x: 1.0 m, y: 1.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">6</td>\n      <td style = \"text-align: center;\">7.5</td>\n      <td style = \"text-align: center;\">txt2</td>\n      <td style = \"text-align: center;\">(x: 2.0 m, y: 2.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">6</td>\n      <td style = \"text-align: center;\">0.06</td>\n      <td style = \"text-align: center;\">txt3</td>\n      <td style = \"text-align: center;\">(x: 3.0 m, y: 3.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">3</td>\n      <td style = \"text-align: center;\">1.29</td>\n      <td style = \"text-align: center;\">txt4</td>\n      <td style = \"text-align: center;\">(x: 4.0 m, y: 4.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">9</td>\n      <td style = \"text-align: center;\">3.64</td>\n      <td style = \"text-align: center;\">txt5</td>\n      <td style = \"text-align: center;\">(x: 5.0 m, y: 5.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">5</td>\n      <td style = \"text-align: center;\">8.05</td>\n      <td style = \"text-align: center;\">txt6</td>\n      <td style = \"text-align: center;\">(x: 6.0 m, y: 6.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">2</td>\n      <td style = \"text-align: center;\">0.11</td>\n      <td style = \"text-align: center;\">txt7</td>\n      <td style = \"text-align: center;\">(x: 7.0 m, y: 7.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">2</td>\n      <td style = \"text-align: center;\">0.64</td>\n      <td style = \"text-align: center;\">txt8</td>\n      <td style = \"text-align: center;\">(x: 8.0 m, y: 8.0 m)</td>\n    </tr>\n    <tr class = \"dataRow\">\n      <td style = \"text-align: center;\">8</td>\n      <td style = \"text-align: center;\">8.46</td>\n      <td style = \"text-align: center;\">txt9</td>\n      <td style = \"text-align: center;\">(x: 9.0 m, y: 9.0 m)</td>\n    </tr>\n  </tbody>\n</table>"

Yes! It is related to how StyledStrings.jl renders to HTML. You can see the difference between the header in one side of the test:

      <th style = \"text-align: center; font-weight: bold;\"><pre><span style=\"font-weight: 700;color: #803d9b;\">a</span></pre></th>

To the other:

      <th style = \"text-align: center; font-weight: bold;\"><span style=\"font-weight: 700; color: #803d9b\">a</span></th>

Notice that in the former we have <pre>.

I remember some discussion about it and having <pre> is just wrong here. Hence, it was probably fixed but not ported to LTS.

Here is the commit:

I dont know what to do in this case because the tests are passing in MacOS with Julia LTS.

Should StyledStrings.jl release a patch to fix the issue on Linux and Windows?

I have absolutely no idea! I cannot understand why the change was applied to LTS in macOS and not in Windows and Linux.

Created an issue:

1 Like

@Ronis_BR I’ve commented out that test temporarily and created a new release.

Looking forward to that. DataFrames.jl is locking further updates.

1 Like

Great to hear of all the improvements!

But, for those of us that were happily depending on v2, is there any sort of migration guidance? Starting from the top of the docs and trying to recall and compare with the previous API for each use-case is not a process I would enjoy much. Knowing what things I need to pay attention to would dramatically improve my likelihood of actually transitioning from v2 to v3.

How about have the author provide one PDF document in version 2 and one PDF document in version 3. Send both documents to the LLM simultaneously and have the LLM migrate them for you?

Thanks @tchr ! That would be great but, unfortunately, I will have no time to create such a document. Nevertheless, usually the calls to pretty_table are simple. Thus, the migration should be quite easy by looking at the documentation. If you have any problems, fell free to ping me here!

1 Like