Compare commits
No commits in common. "a2c8e24ffe1f0fddc75c845daf190a6cce762be8" and "6033eadec5396c5afe6e5ded999ecbe94c9df901" have entirely different histories.
a2c8e24ffe
...
6033eadec5
10
README.md
10
README.md
|
@ -15,10 +15,6 @@ Create an _citation.ini_ in its _configs_-folder:
|
|||
```
|
||||
[Bibtex]
|
||||
file = Literature.bib
|
||||
|
||||
[default]
|
||||
priority = url
|
||||
link = /for-example/link-to-your/biblioprahy
|
||||
```
|
||||
|
||||
And put a _Literature.bib_ BibTex-file into the project's _assets_-folder respectively.
|
||||
|
@ -99,10 +95,4 @@ or
|
|||
|
||||
(AuthorI & AuthorII, 2019)
|
||||
|
||||
#### link parameter
|
||||
Which url is used for your citation's link depends on what you set in the _citation.ini_ file.
|
||||
* If you set _priority_ in the _default_ section to __url__ the link is set to the value of the _url_ field of the entry.
|
||||
* If there's no value in it the default-link you may set with _link_ in the same section is used.
|
||||
* If you set the _link_ parameter of the function it overwrites the former options.
|
||||
|
||||
Thanks to the **lektor-jinja-content** plugin which is a dependency of this plugin you might also use the globals inside your markdown or html contents, too.
|
||||
|
|
|
@ -15,8 +15,6 @@ class CitationPlugin(Plugin):
|
|||
|
||||
config = self.get_config()
|
||||
self.bibfile = config.get('Bibtex.file', []).strip()
|
||||
self.default_prio = config.get('default.priority', []).strip()
|
||||
self.default_link = config.get('default.link', []).strip()
|
||||
|
||||
self.bib_data = parse_file(os.path.join(env.root_path, 'assets', self.bibfile))
|
||||
|
||||
|
@ -48,7 +46,7 @@ class CitationPlugin(Plugin):
|
|||
if len(lAuthor) > 1:
|
||||
|
||||
if n == (len(lAuthor) - 1):
|
||||
authors += " & "
|
||||
authors += " \& "
|
||||
elif n < (len(lAuthor) -1):
|
||||
authors += ", "
|
||||
|
||||
|
@ -79,7 +77,7 @@ class CitationPlugin(Plugin):
|
|||
if len(lAuthor) > 1:
|
||||
|
||||
if n == (len(lAuthor) - 1):
|
||||
authors += " & "
|
||||
authors += " \& "
|
||||
elif n < (len(lAuthor) -1):
|
||||
authors += ", "
|
||||
|
||||
|
@ -225,35 +223,24 @@ class CitationPlugin(Plugin):
|
|||
""".format(eid = id, link = link, authors = authors, pubYear = year, title = title, edition = edition, publisher = publisher, editors = editors, pages = pages, issbn = issbn, note = note)
|
||||
return output
|
||||
|
||||
def citation_base_cite(self,id,link="",output=""):
|
||||
def citation_full_cite(self,id,link=""):
|
||||
e = self.citation_entry(id)
|
||||
|
||||
if len(link) > 1:
|
||||
link = link
|
||||
elif self.default_prio == "url":
|
||||
link = self.get_url(e)
|
||||
if len(link) < 2:
|
||||
link = self.default_link
|
||||
else:
|
||||
link = self.default_link
|
||||
|
||||
authors = self.get_authors_short(e)
|
||||
year = self.get_pubYear(e)
|
||||
output = output.format(link = link, id = id, authors = authors, pubYear = year)
|
||||
return output
|
||||
|
||||
def citation_full_cite(self,id,link=""):
|
||||
output = self.citation_base_cite(id,link="",output="""<a href=\"{link}#{id}\" class=\"litref\">({authors}, {pubYear})</a>""")
|
||||
output = """<a href=\"{link}#{id}\" class=\"litref\">({authors}, {pubYear})</a>""".format(link = link, id = id, authors = authors, pubYear = year)
|
||||
return output
|
||||
|
||||
def citation_full_citeNP(self,id,link=""):
|
||||
output = self.citation_base_cite(id,link="",output="""<a href=\"{link}#{id}\" class=\"litref\">{authors} ({pubYear})</a>""")
|
||||
e = self.citation_entry(id)
|
||||
authors = self.get_authors_short(e)
|
||||
year = self.get_pubYear(e)
|
||||
output = """<a href=\"{link}#{id}\" class=\"litref\">{authors} ({pubYear})</a>""".format(link = link, id = id, authors = authors, pubYear = year)
|
||||
return output
|
||||
|
||||
def on_setup_env(self, **extra):
|
||||
def decode_filter(value):
|
||||
""" Make sure that special chars like german umlaute or accents are displayed in unicode """
|
||||
return LatexNodes2Text().latex_to_text(value.replace(" & ", " \& "))
|
||||
return LatexNodes2Text().latex_to_text(value)
|
||||
|
||||
self.env.jinja_env.globals['citation_entries'] = self.citation_entries
|
||||
self.env.jinja_env.globals['citation_entry'] = self.citation_entry
|
||||
|
|
Loading…
Reference in New Issue