mirror of
https://github.com/TeachBooks/template.git
synced 2026-11-13 14:45:52 +00:00
massive transfer of risk-reliability book
This commit is contained in:
parent
6697c0f5f8
commit
3d24a01439
152 changed files with 57886 additions and 0 deletions
0
book/_ext/pybtexapastyle/names/__init__.py
Normal file
0
book/_ext/pybtexapastyle/names/__init__.py
Normal file
39
book/_ext/pybtexapastyle/names/firstlast.py
Normal file
39
book/_ext/pybtexapastyle/names/firstlast.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# -*- coding:Utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from pybtex.style.names import BaseNameStyle, name_part
|
||||
from pybtex.style.template import join
|
||||
|
||||
|
||||
class NameStyle(BaseNameStyle):
|
||||
|
||||
def format(self, person, abbr=False):
|
||||
r"""
|
||||
Format names similarly to {vv~}{ll}{, jj}{, f.} in BibTeX.
|
||||
|
||||
>>> from pybtex.database import Person
|
||||
>>> name = Person(string=r"Charles Louis Xavier Joseph de la Vall{\'e}e Poussin")
|
||||
>>> firstlast = NameStyle().format
|
||||
|
||||
>>> print(firstlast(name).format().render_as('latex'))
|
||||
Charles Louis Xavier~Joseph de~la Vall{é}e~Poussin
|
||||
>>> print(firstlast(name).format().render_as('html'))
|
||||
Charles Louis Xavier Joseph de la Vall<span class="bibtex-protected">é</span>e Poussin
|
||||
|
||||
>>> print(firstlast(name, abbr=True).format().render_as('latex'))
|
||||
C.~L. X.~J. de~la Vall{é}e~Poussin
|
||||
>>> print(firstlast(name, abbr=True).format().render_as('html'))
|
||||
C. L. X. J. de la Vall<span class="bibtex-protected">é</span>e Poussin
|
||||
|
||||
>>> name = Person(first='First', last='Last', middle='Middle')
|
||||
>>> print(firstlast(name).format().render_as('latex'))
|
||||
First~Middle Last
|
||||
>>> print(firstlast(name, abbr=True).format().render_as('latex'))
|
||||
F.~M. Last
|
||||
|
||||
"""
|
||||
return join[
|
||||
name_part(abbr=abbr)[person.rich_first_names + person.rich_middle_names],
|
||||
name_part(before=' ')[person.rich_prelast_names],
|
||||
name_part(before=' ')[person.rich_last_names],
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue