aboutsummaryrefslogtreecommitdiff
path: root/lib/uoc_exporter.rb
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-07-01 08:40:49 +0200
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-07-01 08:53:56 +0200
commit34e16b7d7a88013578014be0402ab686b03f235b (patch)
tree5ef848d3c44f72ff95a24b123e5da88bc5aef1a2 /lib/uoc_exporter.rb
parent24714068efc5866999311ad482d54f5c7a90c449 (diff)
downloadoperum-34e16b7d7a88013578014be0402ab686b03f235b.tar.gz
operum-34e16b7d7a88013578014be0402ab686b03f235b.zip
lib: Introduce the PlainExporter
This class exports things into plain text. It follows a close format to that of the one for UOC, but without any formatting. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lib/uoc_exporter.rb')
-rw-r--r--lib/uoc_exporter.rb40
1 files changed, 7 insertions, 33 deletions
diff --git a/lib/uoc_exporter.rb b/lib/uoc_exporter.rb
index e8dcc62..9deffc5 100644
--- a/lib/uoc_exporter.rb
+++ b/lib/uoc_exporter.rb
@@ -13,17 +13,14 @@ class UocExporter < BaseExporter
protected
- # Returns the head of a line, containing authors, year, title and, if
- # available, the "inside of" information.
- def head(thing:)
- str = "#{parse_authors(thing:)} (#{thing.year}). #{parse_title(title: thing.title)}."
-
- if thing.insideof.present?
- str += " #{inside_of(thing.insideof)}"
- str += thing.pages.present? ? ", #{thing.pages}." : '.'
- end
+ # Returns the same text with LaTeX \emph applied.
+ def emph(text:)
+ "\\emph{#{text}}"
+ end
- str
+ # Returns the same text with LaTeX \textsc applied.
+ def upper_case(text:)
+ "\\textsc{#{text}}"
end
# Returns the title without underscores and with the expected formatting.
@@ -45,29 +42,6 @@ class UocExporter < BaseExporter
"\\emph{#{str}}"
end
- # Parse the authors as delivered by `thing.authors` and render them in the
- # proper format.
- def parse_authors(thing:)
- str = thing.authors.split(',').map do |author|
- first, last = parse_author(author: author.strip)
- last.blank? ? "\\textsc{#{first}}" : "\\textsc{#{last}}, #{first}"
- end.join('; ')
-
- str += ' (eds.)' if thing.editors
- str
- end
-
- # Returns the proper 'inside of' translated text.
- def inside_of(sub)
- str = if sub.downcase.start_with?(*%w[a e i o u])
- I18n.t('general.insideof-vowel')
- else
- I18n.t('general.insideof')
- end
-
- str + " \\emph{#{sub}}"
- end
-
# Returns the 'body' of the line, which is the rest of it (i.e. note,
# publisher, year).
def body(thing:)