text_fragment

Page actions AI-ready formats and sharing
Open LLM text
Share with AI
Ask Claude Ask ChatGPT Ask Gemini Ask Copilot

Text-fragment deep-link helper for chirp-ui citation UI.

Pure-URL, stdlib-only (Chirp-agnostic, like route_tabs / grid_state). Builds#:~:text=scroll-to-text-fragment links.

Text-fragment deep-link helper for chirp-ui citation UI.

Pure-URL, stdlib-only (Chirp-agnostic, like route_tabs / grid_state). Builds#:~:text=scroll-to-text-fragment links.

text_fragment

Name Type Default Description
type
qualified_name
element_type
description
source_file
line_number
is_autodoc
autodoc_element
_autodoc_template
_autodoc_url_path
_autodoc_page_type
title
doc_content_hash

Symbols on this page

build_text_fragment_url
function
def build_text_fragment_url(href: str, chunk: str | None = None) -> str

Returnhref with a text-fragment so the browser scrolls to/highlights chunk.

>>> build_text_fragment_url("https://x.test/doc", "exact quote")
'https://x.test/doc#:~:text=exact%20quote'

No chunk -> href unchanged. An existing #fragmentis preserved and the text directive is appended with the:~:delimiter per the spec. Percent-encodes- , , and &because they are text-directive syntax characters.

Parameters

Name Type Default Description
href str
chunk str | None None

View source · /home/runner/work/chirp-ui/chirp-ui/site/../src/chirp_ui/text_fragment.py:1