Skip to content

Querying citation labels returns () #4524

Closed as not planned
Closed as not planned

Description

@hbierlee

Description

Hi,

See here. I believe query should work for citation labels like for headings, but it always returns an empty list ():

#bibliography("works.bib")
A queried ref of @knuth returns #{ context query(<knuth>) }

#set heading(numbering: "1.")

= Heading
<sec1>

A queried ref of @sec1 returns #{ context query(<sec1>) }

Given:

@book{knuth,
author = {Knuth, Donald E.},
title = {The art of computer programming, volume 1 (3rd ed.): fundamental algorithms},
year = {1997},
isbn = {0201896834},
publisher = {Addison Wesley Longman Publishing Co., Inc.},
address = {USA}
}

Render:

image

Cheers,

Henk

Reproduction URL

https://typst.app/project/wDfVPd0Ej5rAl9xPsdIBzN

Operating system

Linux

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    on Jul 9, 2024
  2. Enivex commented on Jul 9, 2024

    @Enivex
    Collaborator

    What exactly do you expect it to return?

  3. hbierlee commented on Jul 11, 2024

    @hbierlee
    Author

    Since citations are references, and references are locatable, I'd expect it to return a reference to the citation.

    The context is that I want to show undefined references as TODO's in the document like:

    #show ref: it => {
      if query(it.target).len() > 0 {
        it
      } else {
        it.target
      }
    }
    

    As per the issue I linked above. I can't discern undefined references from citations at the moment.

  4. laurmaedje commented on Jul 11, 2024

    @laurmaedje
    Member

    The thing is that your query searches for elements with the given label, but neither the citation nor the reference have that label attached to themselves, they just reference it.

    I don't think discerning the two cases is currently possible, at least without parsing the bibliography file.

  5. hbierlee commented on Jul 11, 2024

    @hbierlee
    Author

    I see, thanks for your time. Feel free to close as not planned or keep open for a future feature.

  6. laurmaedje commented on Jul 11, 2024

    @laurmaedje
    Member

    Since the query itself is working as intended, I'll close this for now.

  7. added
    introspection
    on Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugintrospection

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions