From 2cf0ffbffc8442efaba12364a07fc0f5e58b7432 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Wed, 20 Mar 2024 11:25:44 +0100 Subject: Support underscore in the exporters on titles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Underscores on titles are meant to be replaced by something else on each exporter (e.g. removed on CSV, or surrounded by \emph on UOC). Signed-off-by: Miquel Sabaté Solà --- lib/csv_exporter.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lib/csv_exporter.rb') diff --git a/lib/csv_exporter.rb b/lib/csv_exporter.rb index a44815d..0463ba6 100644 --- a/lib/csv_exporter.rb +++ b/lib/csv_exporter.rb @@ -12,10 +12,18 @@ class CsvExporter < BaseExporter str end + protected + + # Generate a new CSV line from the given `thing`. def thing_to_csv(thing:) - CSV.generate_line([thing.target, thing.authors, thing.editors, thing.year, thing.title, - thing.note, thing.insideof, thing.url, thing.publisher, thing.kind, - thing.access, thing.bought_at], + CSV.generate_line([thing.target, thing.authors, thing.editors, thing.year, + clean_title(title: thing.title), thing.note, thing.insideof, + thing.url, thing.publisher, thing.kind, thing.access, thing.bought_at], quote_empty: false) end + + # Clean the given title from underscores and other such characters. + def clean_title(title:) + title.delete('_') + end end -- cgit v1.2.3