55from pathlib import Path
66from typing import TYPE_CHECKING , Any , Sequence , cast
77
8+ import natsort
89import numpy as np
910
1011from cmap import Colormap , _util
2425"""
2526CMAP_LINK = '<a href="{url}">' + CMAP_DIV + "</a>"
2627DEV_MODE = "serve" in sys .argv
27- SINERAMP = _util .sineramp ((96 , 512 ))[:, ::- 1 ]
28+ SINERAMP = _util .sineramp ((96 , 826 ))[:, ::- 1 ]
2829
2930
3031def _to_img_tag (
@@ -34,7 +35,7 @@ def _to_img_tag(
3435 img : np .ndarray | None = None ,
3536) -> str :
3637 """Return a base64-encoded <img> tag for the given colormap."""
37- _img = cm ._repr_png_ (width = 256 , height = 1 , img = img )
38+ _img = cm ._repr_png_ (width = 826 , height = 1 , img = img )
3839 data = base64 .b64encode (_img ).decode ("ascii" )
3940 return (
4041 f'<img style="height: { height } " width="{ width } " src="data:image/png;base64,'
@@ -91,7 +92,9 @@ def _cmap_catalog() -> str:
9192 """
9293 categories = set ()
9394 lines = []
94- for cmap_name , details in sorted (CATALOG .items (), key = lambda x : x [0 ].lower ()):
95+ for cmap_name , details in natsort .natsorted (
96+ CATALOG .items (), key = lambda x : x [0 ].lower ()
97+ ):
9598 if "alias" in details :
9699 continue
97100 category = details .get ("category" ) or "Uncategorized"
@@ -185,7 +188,9 @@ def on_page_content(html: str, **kwargs: Any) -> str:
185188
186189def _write_cmap_redirects (site_dir : str ) -> None :
187190 sd = Path (site_dir )
188- for cmap_name , details in sorted (CATALOG .items (), key = lambda x : x [0 ].lower ()):
191+ for cmap_name , details in natsort .natsorted (
192+ CATALOG .items (), key = lambda x : x [0 ].lower ()
193+ ):
189194 if "alias" in details :
190195 cmap_name = cmap_name .replace (":" , "-" )
191196 real = Colormap (details ["alias" ]) # type: ignore
@@ -198,6 +203,6 @@ def _write_cmap_redirects(site_dir: str) -> None:
198203 f .write (content )
199204
200205
201- def on_post_build (config , ** kwargs : Any ) -> None :
206+ def on_post_build (config : dict , ** kwargs : Any ) -> None :
202207 """Copy the extra javascripts to the output directory."""
203208 _write_cmap_redirects (config ["site_dir" ])
0 commit comments