Closed ninfito closed 4 years ago
Thanks for reporting and get deep into this library :)
Actually this is an expected behaviour:
Note: This library considers "type" and "citation-key" as tags. This behavior can be changed implementing your own Listener (more info at the end of this document).
From https://github.com/renanbr/bibtex-parser#vocabulary
There is also a test: testTypeOverriding() using type-overriding.bib file.
Note: I'm NOT rejecting in advance a PR that adds an extra field _type
to the results, which could be done changing the Listener
implementation around these lines.
Thank you for your reply @renanbr.
Yes, consider this issue as a suggestion for future versions. I think that using type
(or any other legal bibtex/biblatex field) as a reserved key for the php-array in Listener::export()
is not the best choice.
In a real-world environment you are forced to implement your own Listener
in order to prevent this obvious collision, otherwise, a bib-file line as
type = {Qualificação de doutorado}
will delete the BibTeX entry (@misc
, @phpthesis
, etc) or replace it with the invalid entry @Qualificação de doutorado
, maybe this is not an expected behaviour.
What if we add allowTypeOverriding(false)
or allowTagOverriding(true)
to the Listener
?
What about adding some methods to the Listener?
class Listener
{
// ...
public function setTypeTagName($tagName) {}
public function setCitationKeyTagName($tagName) {}
public function setOriginalEntryTagName($tagName) {}
}
ping @ninfito
To avoid BC break I think we could store the type (this one define like @misc
) in both _type
and type
key. If parser finds a tag type
this will not override the _type
one.
@TechReport{
type = {resreport},
...
}
@misc{
...
}
will generate something like
[
'_type' => 'TechReport',
'type' => 'resreport',
// ...
];
[
'_type' => 'misc',
'type' => 'misc',
// ...
];
@ninfito, I've tried to fix it with #84 using an insight from @raphael-st
If you have time to review it would be awesome.
Planning to ship this with some new processors.
Consider the next
test.php
Output from
> php test.php | nl
But line 5 in the output should be
or better
Clearly, this is because of the collision between key
type
(php array) and bib-fieldtype
, a legal field in bibtex § 2.2 and biblatex § 4.9.2.13.Maybe the patches...
and
...work, but I'm not sure if this is enough.