From 3c0221ebf7efbd4d792d5ebcacbdb41c96b622e5 Mon Sep 17 00:00:00 2001 From: homer77 Date: Fri, 21 Jan 2022 13:35:51 +0100 Subject: [PATCH] Formating and linking of short citation. --- lektor_citation.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lektor_citation.py b/lektor_citation.py index 2697a58..51e1d85 100644 --- a/lektor_citation.py +++ b/lektor_citation.py @@ -24,17 +24,23 @@ class CitationPlugin(Plugin): def citation_entry(self, id): return self.bib_data.entries[id] - def citation_short_output(self, id, link="?"): + def citation_short_output(self, id, link=None): e = self.citation_entry(id) - link = link+"#"+id + if "url" in e.fields.keys() and len(e.fields['url']) > 0: + link = e.fields['url'] + else: + link = "?" authors = "" lAuthor = e.persons['author'] n = 1 for author in lAuthor: - if len(author.prelast_names) > 0: - authors += str(author.prelast_names) + prelast = author.prelast_names + if len(prelast) > 0: + for item in prelast: + authors += "{i} ".format(i = str(item)) authors += str(author.last_names[0]) + if len(lAuthor) > 1: if n == (len(lAuthor) - 1): @@ -48,6 +54,7 @@ class CitationPlugin(Plugin): year = e.fields['year'] edition = "" if 'edition' in e.fields.keys(): + edition = e.fields['edition'] edition = " ({ed}. Aufl.)".format(ed = edition) else: edition = "" @@ -57,7 +64,7 @@ class CitationPlugin(Plugin): publisher = e.fields['publisher'] if 'address' in e.fields.keys(): location = e.fields['address'] - publisher = " {location}:{publisher}.".format(location = location, publisher = publisher) + publisher = " {location}: {publisher}.".format(location = location, publisher = publisher) elif publisher: publisher = " {publisher}.".format(publisher = publisher) else: