Prework
Description
Links with spaces used in markdown formatted columns don't render as links.
Reproducible example
(A slightly modified version of one of the examples)
I create links to an API where parameters sometimes contain spaces. This example shows the undesired rendering.
from great_tables import GT, html
from great_tables.data import towny
towny_mini = (
towny[["name", "website", "density_2021", "land_area_km2", "latitude", "longitude"]]
.sort_values("density_2021", ascending=False)
.head(10)
)
towny_mini["url_name"] = ["["] + towny_mini["name"] + ["]"] + ["("] + towny_mini["website"] + [")"]
towny_mini["location"] = (
["[map](http://maps.google.com/?ie=UTF8&hq=&ll="]
+ towny_mini["latitude"].astype(str)
+ [","]
+ towny_mini["longitude"].astype(str)
# Adding example attribute that contains a space
+ ["&z=13&spaced attr=True)"]
)
(
GT(
towny_mini[["url_name", "location", "land_area_km2", "density_2021"]],
rowname_col="url_name",
)
.tab_header(
title="The Municipalities of Ontario",
subtitle="The top 10 highest population density in 2021",
)
.tab_stubhead(label="Municipality")
.fmt_markdown(columns=["url_name", "location"])
.fmt_number(columns=["land_area_km2", "density_2021"], decimals=1)
.cols_label(
land_area_km2=html("land area, <br>km<sup>2</sup>"),
density_2021=html("density, <br>people/km<sup>2</sup>"),
)
)
Expected result
Development environment
- Operating System: Databricks, Google Colab
- Pointblank Version: 0.18.0 (Databricks), 0.19.0 (Colab)
Additional context
I have only run into the issue with spaces so far. I'm not sure if there are any other characters that should be encoded for the URI based on the markdown's link capabilities.
I looked at gt-extras' with_hypterlink function as well, it doesn't appear to handle this scenario.
I have been using the following workaround for spaces. I just replace the spaces with %20 and links work as expected.
from great_tables import GT, html
from great_tables.data import towny
towny_mini = (
towny[["name", "website", "density_2021", "land_area_km2", "latitude", "longitude"]]
.sort_values("density_2021", ascending=False)
.head(10)
)
towny_mini["url_name"] = ["["] + towny_mini["name"] + ["]"] + ["("] + towny_mini["website"] + [")"]
towny_mini["location"] = (
["[map](http://maps.google.com/?ie=UTF8&hq=&ll="]
+ towny_mini["latitude"].astype(str)
+ [","]
+ towny_mini["longitude"].astype(str)
+ ["&z=13&spaced attr=True)"]
)
towny_mini["location"] = towny_mini["location"].str.replace(" ", "%20")
(
GT(
towny_mini[["url_name", "location", "land_area_km2", "density_2021"]],
rowname_col="url_name",
)
.tab_header(
title="The Municipalities of Ontario",
subtitle="The top 10 highest population density in 2021",
)
.tab_stubhead(label="Municipality")
.fmt_markdown(columns=["url_name", "location"])
.fmt_number(columns=["land_area_km2", "density_2021"], decimals=1)
.cols_label(
land_area_km2=html("land area, <br>km<sup>2</sup>"),
density_2021=html("density, <br>people/km<sup>2</sup>"),
)
)
Prework
Description
Links with spaces used in markdown formatted columns don't render as links.
Reproducible example
(A slightly modified version of one of the examples)
I create links to an API where parameters sometimes contain spaces. This example shows the undesired rendering.
Expected result
Development environment
Additional context
I have only run into the issue with spaces so far. I'm not sure if there are any other characters that should be encoded for the URI based on the markdown's link capabilities.
I looked at gt-extras'
with_hypterlinkfunction as well, it doesn't appear to handle this scenario.I have been using the following workaround for spaces. I just replace the spaces with
%20and links work as expected.