seboettg / citeproc-php

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

Include suffixes in lambda functions #100

Closed kchoong closed 2 years ago

kchoong commented 3 years ago

Hello @seboettg,

I have a question regarding the custom lambda functions.

For example I have this additional markup:

$additionalMarkup = [
    "bibliography" => [
        "title" => function($cslItem, $renderedText) {
            return '<span class="citeproc-title">' . $renderedText . '</span>';
        },
        "citation-number" => function($cslItem, $renderedText) {
            return '<span class="citation-number">' . $cslItem->citationNumber . '</span>';
        }
    ]
];

and the CSL for the LNCS (springer-lecture-notes-in-computer-science.csl) states:

<text variable="citation-number" suffix="."/>

This would result for the first entry in the bibliography:

<span class="citation-number">1</span>.

Now is there currently a way to include suffixes like the punctuation above within the lambda function or is this something considered to be integrated in the future?

The result I want to reach would look like following instead:

<span class="citation-number">1.</span>

Regards, kchoong

seboettg commented 3 years ago

Hi @kchoong!

I guess this is not possible at the moment. Some adjustments are necessary for that. The "lambda" functions must be changed so that the markup has to embrace affixes and other style options. If necessary, it would be useful to make this configurable in the $additionalMarkup.

I can't promise that I will get to it soon. But if it helps, I'm happy about a pull request from you.

seboettg commented 2 years ago

@kchoong please check if this issue is solved with new versions

kchoong commented 2 years ago

Hey @seboettg, yes this fixed my issue, thank you!