@@ -611,20 +611,17 @@ def render_bibliography_to_strings(
611611 }
612612
613613 try :
614- entries = _prepare_citeproc_entries (
615- resolution_result .citations .values (),
616- )
617- style_name = _resolve_csl_style (style )
618- style_obj = CitationStylesStyle (style_name , validate = False , locale = locale )
614+ entries = list (resolution_result .citations .values ())
615+ style_obj = CitationStylesStyle (style , validate = False , locale = locale )
619616 source = CiteProcJSON (entries )
620617 bibliography = CitationStylesBibliography (style_obj , source , formatter .plain )
621618
622- for item_id in source :
623- citation = Citation ([CitationItem (item_id )])
619+ for item in source . items :
620+ citation = Citation ([CitationItem (item . id )])
624621 bibliography .register (citation )
625622
626623 rendered = [str (entry ) for entry in bibliography .bibliography ()]
627- return rendered , {"renderer" : "citeproc" , "style" : style , "locale" : locale }
624+ return rendered , {"renderer" : "citeproc-py " , "style" : style , "locale" : locale }
628625 except Exception as exc : # pragma: no cover - defensive
629626 return _render_compact (resolution_result ), {
630627 "renderer" : "fallback" ,
@@ -681,45 +678,6 @@ def _extract_year(citation: Dict[str, Any]) -> Optional[int]:
681678 return None
682679
683680
684- def _prepare_citeproc_entries (
685- citations : Iterable [Dict [str , Any ]],
686- ) -> List [Dict [str , Any ]]:
687- """Ensure minimal CSL fields are present for citeproc rendering."""
688-
689- prepared : List [Dict [str , Any ]] = []
690- for index , citation in enumerate (citations , start = 1 ):
691- normalized = dict (citation )
692-
693- citation_id = normalized .get ("id" )
694- normalized ["id" ] = (
695- str (citation_id ) if citation_id not in [None , "" ] else str (index )
696- )
697-
698- if not normalized .get ("type" ):
699- normalized ["type" ] = "article-journal"
700-
701- # Remove internal metadata that citeproc does not understand
702- normalized .pop ("resolution" , None )
703-
704- # citeproc expects an iterable for author names
705- if normalized .get ("author" ) is None :
706- normalized ["author" ] = []
707-
708- prepared .append (normalized )
709-
710- return prepared
711-
712-
713- def _resolve_csl_style (style : str ) -> str :
714- """Map common aliases to valid CSL style identifiers."""
715-
716- aliases = {
717- "chicago" : "chicago-author-date" ,
718- }
719- normalized = style .lower ()
720- return aliases .get (normalized , normalized )
721-
722-
723681def _import_citeproc ():
724682 """Import citeproc modules, isolated for easier testing."""
725683
0 commit comments