From 3236996b18fb91e29c6cfb411336a7d1328cf853 Mon Sep 17 00:00:00 2001 From: Vaughn Kottler Date: Sat, 28 Dec 2024 19:28:28 -0600 Subject: [PATCH] 5.8.4 - Better rendering for markdown tables --- .github/workflows/python-package.yml | 2 +- README.md | 4 ++-- local/configs/package.yaml | 2 +- local/variables/package.yaml | 2 +- pyproject.toml | 2 +- runtimepy/__init__.py | 4 ++-- runtimepy/net/html/bootstrap/elements.py | 24 ++++++++++++++++++++++-- runtimepy/requirements.txt | 2 +- 8 files changed, 31 insertions(+), 11 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 1d090af4..0d2e1703 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -77,7 +77,7 @@ jobs: - run: | mk python-release owner=vkottler \ - repo=runtimepy version=5.8.3 + repo=runtimepy version=5.8.4 if: | matrix.python-version == '3.12' && matrix.system == 'ubuntu-latest' diff --git a/README.md b/README.md index c2556701..e116c626 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ ===================================== generator=datazen version=3.1.4 - hash=a0578deccfc29186901fc54d3849b52b + hash=f89c565370dd68d4215345aeab6feff4 ===================================== --> -# runtimepy ([5.8.3](https://pypi.org/project/runtimepy/)) +# runtimepy ([5.8.4](https://pypi.org/project/runtimepy/)) [![python](https://img.shields.io/pypi/pyversions/runtimepy.svg)](https://pypi.org/project/runtimepy/) ![Build Status](https://github.com/vkottler/runtimepy/workflows/Python%20Package/badge.svg) diff --git a/local/configs/package.yaml b/local/configs/package.yaml index c3d70fda..fae3fad8 100644 --- a/local/configs/package.yaml +++ b/local/configs/package.yaml @@ -8,7 +8,7 @@ time_command: true requirements: - aiofiles - - vcorelib>=3.4.7 + - vcorelib>=3.4.8 - svgen>=0.7.4 - websockets - psutil diff --git a/local/variables/package.yaml b/local/variables/package.yaml index 4e2082ce..f274a496 100644 --- a/local/variables/package.yaml +++ b/local/variables/package.yaml @@ -1,5 +1,5 @@ --- major: 5 minor: 8 -patch: 3 +patch: 4 entry: runtimepy diff --git a/pyproject.toml b/pyproject.toml index 263a175f..5e898423 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__" [project] name = "runtimepy" -version = "5.8.3" +version = "5.8.4" description = "A framework for implementing Python services." readme = "README.md" requires-python = ">=3.12" diff --git a/runtimepy/__init__.py b/runtimepy/__init__.py index ba853dcb..a77ad95c 100644 --- a/runtimepy/__init__.py +++ b/runtimepy/__init__.py @@ -1,7 +1,7 @@ # ===================================== # generator=datazen # version=3.1.4 -# hash=b65d0c030290cfc108e2e5e85293e331 +# hash=99838ab674af55409015e5abdd55fc6e # ===================================== """ @@ -10,7 +10,7 @@ DESCRIPTION = "A framework for implementing Python services." PKG_NAME = "runtimepy" -VERSION = "5.8.3" +VERSION = "5.8.4" # runtimepy-specific content. METRICS_NAME = "metrics" diff --git a/runtimepy/net/html/bootstrap/elements.py b/runtimepy/net/html/bootstrap/elements.py index e3b907a4..dcaac725 100644 --- a/runtimepy/net/html/bootstrap/elements.py +++ b/runtimepy/net/html/bootstrap/elements.py @@ -165,8 +165,14 @@ def slider( return elem +TABLE_CLASSES = ["table", "table-hover", "table-striped", "table-bordered"] + + def centered_markdown( - parent: Element, markdown: str, *container_classes: str + parent: Element, + markdown: str, + *container_classes: str, + table_classes: list[str] = None, ) -> Element: """Add centered markdown.""" @@ -188,7 +194,21 @@ def centered_markdown( with StringIO() as stream: writer = IndentedFileWriter(stream) - writer.write_markdown(markdown) + + if table_classes is None: + table_classes = TABLE_CLASSES + + def render_hook(data: str) -> str: + """Make some adjustments to various element declarations.""" + + if table_classes: + data = data.replace( + "", f'
' + ) + + return data + + writer.write_markdown(markdown, hook=render_hook) div( text=stream.getvalue(), parent=horiz_container, diff --git a/runtimepy/requirements.txt b/runtimepy/requirements.txt index 6d1bfe87..2615c95e 100644 --- a/runtimepy/requirements.txt +++ b/runtimepy/requirements.txt @@ -1,5 +1,5 @@ aiofiles -vcorelib>=3.4.7 +vcorelib>=3.4.8 svgen>=0.7.4 websockets psutil