seboettg / citeproc-php

Full-featured CSL 1.0.1 processor for PHP
MIT License
73 stars 38 forks source link

Add possibility to include affixes in lambda functions, Issue #100, 2 #110

Closed nongenti closed 2 years ago

nongenti commented 2 years ago

Hallo @seboettg,

it is not possible to create a pull request with "Allow edits by maintainers", if owner is an organization. https://github.community/t/how-can-we-enable-allow-edits-from-maintainers-by-default/2847/6

My organization gave me permission to create a user-owned fork in this case.

I hope now all is right.

Regards, Christian

seboettg commented 2 years ago

Hi @nongenti! Now I'm able to add commits to your PR. Thank you for that and sorry for that hassle. But now it's much easier to discuss your suggested changes and to work on it in a more collaborative way.

I wrote a simple test case for the requirement of issue #100 and unfortunately your changes does not work as expected. The setup of the test case is

$additionalMarkup = [
    "title" => [
        'function' => function ($cslItem, $renderedText) {
            return '<span class="cite-title">' . $renderedText . '</span>';
        },
        'affixes' => false
    ],
    "citation-number" => [
        'function' => function ($cslItem, $renderedText) {
            return '<span class="cite-no">' . $renderedText . '</span>';
        },
        'affixes' => true
    ]
];

Stylesheet: springer-lecture-notes-in-computer-science. You can find the used CSL data in my commit. Anyhow, I would expect that the rendered result is like this:

  <div class="csl-entry"><div class="csl-left-margin"><span class="cite-no">1.</span></div><div class="csl-right-inline">Doe, J., III: <span class="cite-title">My Anonymous Heritage</span>. (2001).</div></div>

But the actual result is:

<div class="csl-entry"><div class="csl-left-margin"><span class="cite-no"><span class="cite-no">1</span>.</span></div><div class="csl-right-inline">Doe, J., III: <span class="cite-title">My Anonymous Heritage</span>. (2001).</div></div>\

The embracing span tag <span class="cite-no">, as defined in $additionalMarkup, appears two times nested in each other.

seboettg commented 2 years ago

Hi @nongenti, do you have any ideas to solve this?

nongenti commented 2 years ago

Hi @seboettg, sorry I've to finish an other project this week. I will look at this next week.

nongenti commented 2 years ago

Hi @seboettg,
the problem was in function renderCitationNumber. In my test cases I never used the citation number, so I don't see this error before. Now your test is running well.

Regards, Christian

nongenti commented 2 years ago

Hi @seboettg, is there any other problem with that?