diff --git a/publi_bib.php b/publi_bib.php index d93cdd9..64c8689 100644 --- a/publi_bib.php +++ b/publi_bib.php @@ -6,12 +6,41 @@ use RenanBr\BibTexParser\Processor; require dirname(__FILE__).'/common.php'; +function removeBoundingBraces($str) { + // Trim whitespace first + $str = trim($str); + + // Check if string starts with { and ends with } + if (strlen($str) >= 2) { + // Remove opening brace if it exists + if ($str[0] === '{') { + $str = substr($str, 1); + } + + // After removing first brace, get new length + $length = strlen($str); + + // Remove closing brace if it exists + if ($length > 0 && $str[$length - 1] === '}') { + $str = substr($str, 0, -1); + } + } + + return $str; +} + $m = setup_mustache(); + // Create and configure a Listener $listener = new Listener(); $listener->addProcessor(new Processor\TagNameCaseProcessor(CASE_LOWER)); +$listener->addProcessor(new NamesProcessor()); +$listener->addProcessor(static function (array $entry) { + $entry['title'] = removeBoundingBraces($entry['title']); + return $entry; +}); // Create a Parser and attach the listener $parser = new Parser(); diff --git a/views/publi_bib_html.mustache b/views/publi_bib_html.mustache index fadb683..b7a5718 100644 --- a/views/publi_bib_html.mustache +++ b/views/publi_bib_html.mustache @@ -48,9 +48,9 @@ span.author:last-child::after {