aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/base_exporter.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/base_exporter.rb b/lib/base_exporter.rb
index a67784e..7879af1 100644
--- a/lib/base_exporter.rb
+++ b/lib/base_exporter.rb
@@ -19,10 +19,20 @@ class BaseExporter
# - 'Name Surname' -> ['Name', 'Surname']
# - 'Compound Name Surname' -> ['Compound Name', 'Surname']
# - 'Name _Surname1 Surname2_' -> ['Name', 'Surname1 Surname2']
+ # - '_Special name_' -> ['Special name', nil]
def parse_author(author:)
+ # Special case: the user might set the whole thing as the name on special
+ # scenarios. In this case everything will be surrounded by
+ # underscores. Hence, if this is the case, then just return the whole thing
+ # as a name with undescores stripped.
+ return [author.delete('_'), nil] if /^\s*_(.+)_\s*$/.match?(author)
+
+ # Other underscore scenarios are handled here.
matches = /(.+)?\s_(.+)_/.match(author)
return matches[1].strip, matches[2].strip if matches&.size == 3
+ # Otherwise we fallback to the usual route.
+
a = author.split
return [author, nil] if a.size == 1