Build structured journal front matter for sn-jnl
This commit is contained in:
1 parent
82542740e7
commit
466abd4ce6
10 files changed
+684
-7
No files matched your search
@@ -478,6 +478,12 @@ struct Parser {
|
||||
pending_table_caption: Option<Vec<Run>>,
|
||||
caption_capture: Option<Vec<Run>>,
|
||||
metadata_capture: Option<(expanded::MetadataField, Vec<Run>)>,
|
||||
author_affiliations: Vec<usize>,
|
||||
pending_author_email: Option<String>,
|
||||
email_capture: Option<Vec<Run>>,
|
||||
affiliation_capture: Option<(usize, Vec<Run>)>,
|
||||
abstract_capture: Option<Vec<Run>>,
|
||||
keywords_capture: Option<Vec<Run>>,
|
||||
framed_box: Option<Vec<Run>>,
|
||||
box_frame: bool,
|
||||
box_width: Option<common::Scaled>,
|
||||
@@ -590,6 +596,12 @@ impl Parser {
|
||||
pending_table_caption: None,
|
||||
caption_capture: None,
|
||||
metadata_capture: None,
|
||||
author_affiliations: Vec::new(),
|
||||
pending_author_email: None,
|
||||
email_capture: None,
|
||||
affiliation_capture: None,
|
||||
abstract_capture: None,
|
||||
keywords_capture: None,
|
||||
framed_box: None,
|
||||
box_frame: true,
|
||||
box_width: None,
|
||||
@@ -787,7 +799,16 @@ impl Parser {
|
||||
self.document.title = value;
|
||||
self.document.title_runs = runs;
|
||||
}
|
||||
expanded::MetadataField::Author => self.document.author = value,
|
||||
expanded::MetadataField::Author => {
|
||||
self.document.author = value;
|
||||
let affiliations = std::mem::take(&mut self.author_affiliations);
|
||||
let email = self.pending_author_email.take();
|
||||
self.document.authors.push(crate::document::AuthorBlock {
|
||||
runs,
|
||||
affiliations,
|
||||
email,
|
||||
});
|
||||
}
|
||||
expanded::MetadataField::Date => self.document.date = value,
|
||||
}
|
||||
}
|
||||
@@ -1006,6 +1027,9 @@ impl Parser {
|
||||
self.finish_metadata(*field);
|
||||
}
|
||||
expanded::FrontendEventKind::PackageLoaded(package) => {
|
||||
if package == "sn-jnl" {
|
||||
self.document.title_style = TitleStyle::Journal;
|
||||
}
|
||||
if package == "arxiv" {
|
||||
self.document.title_style = TitleStyle::Preprint;
|
||||
self.document.author_year_citations = true;
|
||||
@@ -1030,6 +1054,60 @@ impl Parser {
|
||||
self.append_text("\u{F7001}");
|
||||
}
|
||||
}
|
||||
expanded::FrontendEventKind::MetadataShortTitle(short) => {
|
||||
self.document.short_title = Some(short.clone());
|
||||
}
|
||||
expanded::FrontendEventKind::AuthorAffiliations(indices) => {
|
||||
self.author_affiliations = indices.clone();
|
||||
}
|
||||
expanded::FrontendEventKind::MetadataEmailStart => {
|
||||
self.email_capture = Some(Vec::new());
|
||||
}
|
||||
expanded::FrontendEventKind::MetadataEmailEnd => {
|
||||
if let Some(mut runs) = self.email_capture.take() {
|
||||
trim_run_end(&mut runs);
|
||||
let email = runs.iter().map(|run| run.text.as_str()).collect::<String>();
|
||||
self.pending_author_email = Some(email);
|
||||
}
|
||||
}
|
||||
expanded::FrontendEventKind::AffiliationStart(index) => {
|
||||
if self.document.title_style == TitleStyle::Article {
|
||||
self.document.title_style = TitleStyle::Journal;
|
||||
}
|
||||
self.affiliation_capture = Some((*index, Vec::new()));
|
||||
}
|
||||
expanded::FrontendEventKind::AffiliationEnd => {
|
||||
if let Some((index, mut runs)) = self.affiliation_capture.take() {
|
||||
trim_run_end(&mut runs);
|
||||
self.document
|
||||
.affiliations
|
||||
.push(crate::document::Affiliation { index, runs });
|
||||
}
|
||||
}
|
||||
expanded::FrontendEventKind::AbstractStart => {
|
||||
if self.document.title_style == TitleStyle::Article {
|
||||
self.document.title_style = TitleStyle::Journal;
|
||||
}
|
||||
self.abstract_capture = Some(Vec::new());
|
||||
}
|
||||
expanded::FrontendEventKind::AbstractEnd => {
|
||||
if let Some(mut runs) = self.abstract_capture.take() {
|
||||
trim_run_end(&mut runs);
|
||||
self.document.abstract_runs = runs;
|
||||
}
|
||||
}
|
||||
expanded::FrontendEventKind::KeywordsStart => {
|
||||
if self.document.title_style == TitleStyle::Article {
|
||||
self.document.title_style = TitleStyle::Journal;
|
||||
}
|
||||
self.keywords_capture = Some(Vec::new());
|
||||
}
|
||||
expanded::FrontendEventKind::KeywordsEnd => {
|
||||
if let Some(mut runs) = self.keywords_capture.take() {
|
||||
trim_run_end(&mut runs);
|
||||
self.document.keywords = runs;
|
||||
}
|
||||
}
|
||||
expanded::FrontendEventKind::Geometry(settings) => {
|
||||
apply_class_font_size(&mut self.document, settings);
|
||||
apply_geometry(&mut self.document, settings);
|
||||
@@ -1749,6 +1827,31 @@ impl Parser {
|
||||
.expect("page decoration capture was checked")
|
||||
.2;
|
||||
}
|
||||
if self.email_capture.is_some() {
|
||||
return self
|
||||
.email_capture
|
||||
.as_mut()
|
||||
.expect("email capture was checked");
|
||||
}
|
||||
if self.affiliation_capture.is_some() {
|
||||
return &mut self
|
||||
.affiliation_capture
|
||||
.as_mut()
|
||||
.expect("affiliation capture was checked")
|
||||
.1;
|
||||
}
|
||||
if self.abstract_capture.is_some() {
|
||||
return self
|
||||
.abstract_capture
|
||||
.as_mut()
|
||||
.expect("abstract capture was checked");
|
||||
}
|
||||
if self.keywords_capture.is_some() {
|
||||
return self
|
||||
.keywords_capture
|
||||
.as_mut()
|
||||
.expect("keywords capture was checked");
|
||||
}
|
||||
if self.footnote_capture.is_some() {
|
||||
return self
|
||||
.footnote_capture
|
||||
@@ -1764,6 +1867,10 @@ impl Parser {
|
||||
&& self.centered.is_none()
|
||||
&& self.framed_box.is_none()
|
||||
&& self.metadata_capture.is_none()
|
||||
&& self.email_capture.is_none()
|
||||
&& self.affiliation_capture.is_none()
|
||||
&& self.abstract_capture.is_none()
|
||||
&& self.keywords_capture.is_none()
|
||||
&& self.page_decoration_capture.is_none()
|
||||
&& self.caption_capture.is_none()
|
||||
&& self.heading.is_none()
|
||||
|
||||
Reference in new issue
Block a user