feat(donate,quant,tutorials,citations): implement /donate/, Option 3 stadium-pill navbar, 5-episode /quant/ canvas tour, and passage-encoded deep citations (v2.0.19)
This commit is contained in:
1 parent
1182ba0cf2
commit
2114de35bb
17 files changed
+3270
-13
No files matched your search
@@ -312,9 +312,32 @@ def _dispatch_rest_v1_inner(
|
||||
md_text = r_out["contents"][0]["text"]
|
||||
if q_args.get("format") == "raw":
|
||||
return 200, "text/markdown; charset=utf-8", md_text
|
||||
dos_payload: dict[str, Any] = {
|
||||
"dossier_number": num,
|
||||
"uri": uri,
|
||||
"mime_type": "text/markdown",
|
||||
"markdown": md_text,
|
||||
}
|
||||
hl_q = str(q_args.get("highlight", "")).strip()
|
||||
if hl_q:
|
||||
hl_low = hl_q.lower()
|
||||
lines = md_text.splitlines()
|
||||
matched_passages: list[dict[str, Any]] = []
|
||||
for l_idx, ln in enumerate(lines):
|
||||
if hl_low in ln.lower():
|
||||
start_i = max(0, l_idx - 1)
|
||||
end_i = min(len(lines), l_idx + 2)
|
||||
matched_passages.append({
|
||||
"line_number": l_idx + 1,
|
||||
"line": ln,
|
||||
"context": "\n".join(lines[start_i:end_i]),
|
||||
})
|
||||
dos_payload["highlight_query"] = hl_q
|
||||
dos_payload["match_count"] = len(matched_passages)
|
||||
dos_payload["matched_passages"] = matched_passages[:25]
|
||||
return 200, "application/json; charset=utf-8", _wrap_response(
|
||||
path,
|
||||
{"dossier_number": num, "uri": uri, "mime_type": "text/markdown", "markdown": md_text},
|
||||
dos_payload,
|
||||
unwrap=unwrap,
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user