Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create possibility to filter specific citations in "render" function, independently from CSL input data. #39

Merged
merged 6 commits into from
Nov 23, 2017

Conversation

CarlosCraviotto
Copy link
Contributor

Why do we need it? Cos when we are trying to render a citation and it is part of a number of bibliography but it's not the number 1 we will be able to send the field "citation-number" and render with it.

Why do we need it? Cos when we are trying to render a citation and it is part of a number of bibliography but it's not the number 1 we will be able to send the field "citation-number" and render with it.
@coveralls
Copy link

coveralls commented May 31, 2017

Coverage Status

Changes Unknown when pulling 205496c on CarlosCraviotto:patch-1 into ** on seboettg:master**.

@seboettg
Copy link
Owner

seboettg commented May 31, 2017

Hi Carlos!
Thank you for your PR. I'm a bit confused. According to csl-data schema there is a property citation-number but this discussion indicates that there isn't a property, and citation-number is just determined by the order in which the items are stored in the array.

Do you have any idea? And where do you get your CSL input data from? I haven't seen an example yet which uses citation-number property.

@CarlosCraviotto
Copy link
Contributor Author

Hi Sebastian,
Thanks for your quick answer.
My problem came up when I'm trying to render an individual citation and it's part of a bibliography list, in this case, a lot of standards (elsevier-vancouver) are using the citation-number as a reference to match the citation with The bibliography therefore I will need a property to declare it and the citation-number looks like a good choose.

@seboettg
Copy link
Owner

I'm not sure whether I understood the actual problem completely.
In case of "Elsevier Vancouver" there are two possibilities:

  1. the citation-number is a non-empty property of your input data: In this case, the value (i, 1..n) of the property will be used as reference as well in citation as in bibliography.
  2. the citation-number doesn't exist: In this case the array key (j, 0..n) but increased by 1 will be used.
    The result is the same, in both cases.

@CarlosCraviotto
Copy link
Contributor Author

I will give you an example:
I have this two bibliographies:

[1] World Health Organization. Drinking water [Internet]. Geneva: World Health Organization; 2015 Jun [cited 2015 Jul 20]. Available from: http://www.who.int/mediacentre/factsheets/fs391/en/
[2] Heart Foundation (AU). Dads and carers [Internet]. Deakin, ACT (Australia): Heart Foundation (AU); 2015 [cited 2015 Jun 30]. Available from: http://www.heartfoundation.org.au/healthy-eating/mums-united/about-mums-united/Pages/Dads-and-Carers.aspx

And now I want to render as a citation just the Heart Foundation (AU). As I'm using the vancouver style, the csl processor will return [1] because when I'm rendering it I'm sending the data for this one and I don't have any way (I didn't find any) to tell to the processor this is the second one.
Thanks a lot for your time.

@seboettg
Copy link
Owner

seboettg commented Jun 6, 2017

Okay, I understand the problem. But I guess we need a different approach, which enables citeproc users to filter specific citations without changing the CSL input data. Another advantage for this way is also that we're closer to citeproc-js, the reference implementation of a CSL processor and I'm able to still use the test-suite.
I'll push a suggestion soon.

@coveralls
Copy link

coveralls commented Jun 6, 2017

Coverage Status

Changes Unknown when pulling 36b768b on CarlosCraviotto:patch-1 into ** on seboettg:master**.

Sebastian Böttger added 2 commits June 6, 2017 14:07
@coveralls
Copy link

coveralls commented Jun 6, 2017

Coverage Status

Changes Unknown when pulling 549f672 on CarlosCraviotto:patch-1 into ** on seboettg:master**.

@seboettg
Copy link
Owner

seboettg commented Jun 6, 2017

This approach enables you to filter specific citation items by a filter array which you can pass to the render function while rendering citations. In that array are one or more stdClass objects containing an id property which references the item that should be rendered.

$dataString = '[
            {
                "id": "ITEM-1",
                "title": "Book 1",
                "type": "book"
            },
            {
                "id": "ITEM-2",
                "title": "Book 2",
                "type": "book"
            },
            {
                "id": "ITEM-3",
                "title": "Book 3",
                "type": "book"
            }
        ]';
$data = json_decode($dataString);
$filter = json_decode('[{"id":"ITEM-3"}]');
$citeProc->render($data, "citation", $filter);

Another example you will find in example/index.php.

What do you think?

@CarlosCraviotto
Copy link
Contributor Author

Great!!! I like it 👍

@coveralls
Copy link

coveralls commented Jun 6, 2017

Coverage Status

Changes Unknown when pulling 315715a on CarlosCraviotto:patch-1 into ** on seboettg:master**.

@seboettg seboettg added this to the Version 2.1 milestone Jun 12, 2017
@seboettg seboettg changed the title Update Text.php create possibility to filter specific citations in render function, independently from CSL input data. Jun 12, 2017
@seboettg seboettg changed the title create possibility to filter specific citations in render function, independently from CSL input data. create possibility to filter specific citations in "render" function, independently from CSL input data. Jun 12, 2017
@seboettg seboettg closed this Jun 12, 2017
@seboettg seboettg reopened this Nov 19, 2017
@coveralls
Copy link

coveralls commented Nov 19, 2017

Coverage Status

Coverage increased (+0.07%) to 91.557% when pulling 315715a on CarlosCraviotto:patch-1 into b916e4e on seboettg:master.

@seboettg seboettg merged commit 315715a into seboettg:master Nov 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants