Skip to content

Cross reference direct to wrong page with same title name or label in two page #149

@tonyddg

Description

@tonyddg

For html target, if the target page has a same title (reference by heading-reference) or label in the current page, the cross reference will always direct to current page no matter what give to argument path.

With following is my test code in ./sample-page.typ :

#import "/book.typ": book-page, cross-link, templates
#show: book-page.with(title: "Hello, typst")
#let p-self = "/sample-page.typ"
#let p-target = "/test.typ"

= Heading

== Title1 <title1> 

#lorem(400)

== Title2

#lorem(400)

== Link

Work properly for reference to same page
- #cross-link(p-self, reference: <title1>)[Link to Title1]
- #cross-link(p-self, reference: templates.heading-reference([== Title2]))[Link to Title2]

Went wrong for reference to other page, and still direct to label in `sample-page.typ` not `./test.typ`
- #cross-link(p-target, reference: <title1>)[Link to Title1 in test.typ]
- #cross-link(p-target, reference: templates.heading-reference([== Title2]))[Link to Title2 in test.typ]

Work properly for reference to other page
- #cross-link(p-target, reference: <title3>)[Link to Title3 in test.typ]
- #cross-link(p-target, reference: templates.heading-reference([== Title4]))[Link to Title4 in test.typ]

and code in ./test.typ (both chapter has configured in book.typ) :

#import "/book.typ": book-page, cross-link, templates
#show: book-page.with(title: "Hello, typst")

= Testtitle

== Title1 <title1> 

== Title2

== Title3 <title3> 

== Title4

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions