Skip to content

Commit

Permalink
modified: .github/actions/recent-posts/main.py
Browse files Browse the repository at this point in the history
	- Dumped rich.table because it doesn't format nicely in markdown.
  • Loading branch information
it176131 committed Jan 3, 2025
1 parent 075635e commit ac4afba
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions .github/actions/recent-posts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from pydantic_xml.model import (
attr, BaseXmlModel, computed_element, element, wrapped
)
from rich.console import Console
from rich.table import Table
from typer import Typer
from typer.params import Argument

Expand Down Expand Up @@ -58,19 +56,9 @@ def main(
text = f.read()

pattern = r"(?<=<!-- BLOG START -->)[\S\s]*(?=<!-- BLOG END -->)"
table = Table(*("Title", "Author", "Published"))
table.add_row(
*(
f"[{model.entry.title}]({model.entry.link})",
model.entry.author,
model.entry.published.strftime("%Y-%m-%d %I:%M%p"),
)
repl = (
f"- [{model.entry.title}]({model.entry.link}) by {model.entry.author}"
)
console = Console()
with console.capture() as capture:
console.print(table)

repl = capture.get()
new_text = re.sub(pattern=pattern, repl=f"\n{repl}\n", string=text)
with readme.open(mode="w") as f:
f.write(new_text)
Expand Down

0 comments on commit ac4afba

Please sign in to comment.