commit 9f4df64f2317e76fa3844bf11cb24c526436be6e
Author: Juergen Spitzmueller <[email protected]>
Date: Sun Mar 19 11:45:42 2017 +0100
Allow for simple conditions in name scheme.
I.e., only output a comma between last and first name if there is
a first name.
---
lib/layouts/stdciteformats.inc | 4 ++--
src/BiblioInfo.cpp | 11 ++++++++++-
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/lib/layouts/stdciteformats.inc b/lib/layouts/stdciteformats.inc
index 9657375..67530bf 100644
--- a/lib/layouts/stdciteformats.inc
+++ b/lib/layouts/stdciteformats.inc
@@ -32,9 +32,9 @@ CiteFormat default
# Macros
#
# Scheme of the first author in the bibliography
- !firstnameform %surname%, %prename%
+ !firstnameform %surname%{%prename%[[, %prename%]]}
# Scheme of other authors in the bibliography
- !othernameform %surname%, %prename%
+ !othernameform %surname%{%prename%[[, %prename%]]}
# Scheme of the first name in later parts (such as book editor)
!firstbynameform %prename% %surname%
# Scheme of other authors in later parts (such as book editor)
diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp
index 6dc976c..1d15f2f 100644
--- a/src/BiblioInfo.cpp
+++ b/src/BiblioInfo.cpp
@@ -151,7 +151,16 @@ docstring constructName(docstring const & name, string
const scheme)
// to a given scheme
docstring const prename = nameParts(name).first;
docstring const surname = nameParts(name).second;
- docstring result = from_ascii(scheme);
+ string res = scheme;
+ static regex const
reg1("(.*)(\\{%prename%\\[\\[)([^\\]]+)(\\]\\]\\})(.*)");
+ smatch sub;
+ if (regex_match(scheme, sub, reg1)) {
+ res = sub.str(1);
+ if (!prename.empty())
+ res += sub.str(3);
+ res += sub.str(5);
+ }
+ docstring result = from_ascii(res);
result = subst(result, from_ascii("%prename%"), prename);
result = subst(result, from_ascii("%surname%"), surname);
return result;