Fix sexp parse errors: avoid literal parentheses in sexp string args

The sexp parser doesn't handle "(" and ")" as string literals
inside expressions. Use raw! with pre-formatted strings instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-28 14:20:41 +00:00
parent 09b5a5b4f6
commit 0d1ce92e52
2 changed files with 10 additions and 8 deletions

View File

@@ -687,9 +687,9 @@ async def render_following_page(ctx: dict, actors: list, total: int,
items_html = _actor_list_items_html(actors, 1, "following", set(), actor)
content = sexp(
'(h1 :class "text-2xl font-bold mb-6" "Following "'
' (span :class "text-stone-400 font-normal" "(" (raw! total) ")"))'
' (span :class "text-stone-400 font-normal" (raw! count-str)))'
'(div :id "actor-list" (raw! items))',
total=str(total), items=items_html,
**{"count-str": f"({total})"}, items=items_html,
)
return _social_page(ctx, actor, content_html=content,
title="Following \u2014 Rose Ash")
@@ -706,9 +706,9 @@ async def render_followers_page(ctx: dict, actors: list, total: int,
items_html = _actor_list_items_html(actors, 1, "followers", followed_urls, actor)
content = sexp(
'(h1 :class "text-2xl font-bold mb-6" "Followers "'
' (span :class "text-stone-400 font-normal" "(" (raw! total) ")"))'
' (span :class "text-stone-400 font-normal" (raw! count-str)))'
'(div :id "actor-list" (raw! items))',
total=str(total), items=items_html,
**{"count-str": f"({total})"}, items=items_html,
)
return _social_page(ctx, actor, content_html=content,
title="Followers \u2014 Rose Ash")
@@ -928,13 +928,14 @@ async def render_profile_page(ctx: dict, actor: Any, activities: list,
' (h1 :class "text-2xl font-bold" (raw! dname))'
' (p :class "text-stone-500" "@" (raw! username) "@" (raw! domain))'
' (raw! summary))'
' (h2 :class "text-xl font-bold mb-4" "Activities (" (raw! total) ")")'
' (h2 :class "text-xl font-bold mb-4" (raw! activities-heading))'
' (raw! activities))',
dname=str(escape(display_name)),
username=str(escape(actor.preferred_username)),
domain=str(escape(ap_domain)),
summary=summary_html,
total=str(total), activities=activities_html,
**{"activities-heading": f"Activities ({total})"},
activities=activities_html,
)
return _social_page(ctx, actor, content_html=content,