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:
@@ -716,8 +716,9 @@ def _day_row_html(ctx: dict, entry) -> str:
|
|||||||
'(td :class "p-2 align-top w-1/6" (div :class "text-xs font-medium"'
|
'(td :class "p-2 align-top w-1/6" (div :class "text-xs font-medium"'
|
||||||
' (a :href h :class pc :hx-get h :hx-target "#main-panel" :hx-select "#main-panel"'
|
' (a :href h :class pc :hx-get h :hx-target "#main-panel" :hx-select "#main-panel"'
|
||||||
' :hx-swap "outerHTML" :hx-push-url "true" sn)'
|
' :hx-swap "outerHTML" :hx-push-url "true" sn)'
|
||||||
' (span :class "text-stone-600 font-normal" (str "(" ts te ")"))))',
|
' (span :class "text-stone-600 font-normal" (raw! time-str))))',
|
||||||
h=slot_href, pc=pill_cls, sn=slot.name, ts=time_start, te=time_end,
|
h=slot_href, pc=pill_cls, sn=slot.name,
|
||||||
|
**{"time-str": f"({time_start}{time_end})"},
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
start = entry.start_at.strftime("%H:%M") if entry.start_at else ""
|
start = entry.start_at.strftime("%H:%M") if entry.start_at else ""
|
||||||
|
|||||||
@@ -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)
|
items_html = _actor_list_items_html(actors, 1, "following", set(), actor)
|
||||||
content = sexp(
|
content = sexp(
|
||||||
'(h1 :class "text-2xl font-bold mb-6" "Following "'
|
'(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))',
|
'(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,
|
return _social_page(ctx, actor, content_html=content,
|
||||||
title="Following \u2014 Rose Ash")
|
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)
|
items_html = _actor_list_items_html(actors, 1, "followers", followed_urls, actor)
|
||||||
content = sexp(
|
content = sexp(
|
||||||
'(h1 :class "text-2xl font-bold mb-6" "Followers "'
|
'(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))',
|
'(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,
|
return _social_page(ctx, actor, content_html=content,
|
||||||
title="Followers \u2014 Rose Ash")
|
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))'
|
' (h1 :class "text-2xl font-bold" (raw! dname))'
|
||||||
' (p :class "text-stone-500" "@" (raw! username) "@" (raw! domain))'
|
' (p :class "text-stone-500" "@" (raw! username) "@" (raw! domain))'
|
||||||
' (raw! summary))'
|
' (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))',
|
' (raw! activities))',
|
||||||
dname=str(escape(display_name)),
|
dname=str(escape(display_name)),
|
||||||
username=str(escape(actor.preferred_username)),
|
username=str(escape(actor.preferred_username)),
|
||||||
domain=str(escape(ap_domain)),
|
domain=str(escape(ap_domain)),
|
||||||
summary=summary_html,
|
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,
|
return _social_page(ctx, actor, content_html=content,
|
||||||
|
|||||||
Reference in New Issue
Block a user