formatter/typst.py: add placeholder label for section references
This commit is contained in:
parent
35267cfa34
commit
b33da2a881
@ -19,19 +19,21 @@ def format_pdf_link(ref: PDFReference) -> str:
|
|||||||
format_path = str(ref.filepath.absolute())
|
format_path = str(ref.filepath.absolute())
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
|
default_label = ""
|
||||||
|
|
||||||
match ref:
|
match ref:
|
||||||
case PDFPage():
|
case PDFPage():
|
||||||
params["page"] = ref.page
|
params["page"] = ref.page
|
||||||
case PDFSection():
|
case PDFSection():
|
||||||
params["section"] = ref.title
|
params["section"] = ref.title
|
||||||
|
default_label = ref.title
|
||||||
case _ as obj:
|
case _ as obj:
|
||||||
assert_never(obj)
|
assert_never(obj)
|
||||||
|
|
||||||
if relative:
|
if relative:
|
||||||
return f'#lref("{format_path}?{urlencode(params)}", pdfref: true)[]'
|
return f'#lref("{format_path}?{urlencode(params)}", pdfref: true)[{default_label}]'
|
||||||
else:
|
else:
|
||||||
return f'#link("pdfref://{format_path}?{urlencode(params)}")[]'
|
return f'#link("pdfref://{format_path}?{urlencode(params)}")[{default_label}]'
|
||||||
|
|
||||||
def ref(ref: Reference) -> str:
|
def ref(ref: Reference) -> str:
|
||||||
"""Formats a Reference."""
|
"""Formats a Reference."""
|
||||||
|
Loading…
Reference in New Issue
Block a user