Keep an iD marker for ORCID author graphics
Author metadata contains an ORCID PDF icon inside href; the author block was dropping the include and showing only the name. Replace orcid.pdf includegraphics and orcidlink with an iD text marker so the author line keeps a recognisable ORCID cue. This is not the vector logo; it is a text approximation. Test count is 1077.
This commit is contained in:
1 parent
8b742dacb3
commit
3780aef88c
6 files changed
+60
-10
No files matched your search
+50
-1
@@ -12605,13 +12605,52 @@ fn rename_abstract_heading(paragraphs: &mut [SourceParagraph], name: &str) {
|
||||
/// Split an author block on `\\` and `\And` into separately centred lines.
|
||||
/// The class layouts put each affiliation on its own row; collapsing them to
|
||||
/// one paragraph loses the author/affiliation structure entirely.
|
||||
/// Replace the two common ORCID markers with the ORCID wordmark `iD`.
|
||||
/// The vector icon itself is not decoded, but the author block keeps a
|
||||
/// recognisable marker instead of silently dropping it.
|
||||
fn author_orcid_marker(text: &str) -> String {
|
||||
let mut out = String::new();
|
||||
let mut rest = text;
|
||||
while let Some(position) = rest.find('\\') {
|
||||
out.push_str(&rest[..position]);
|
||||
let after = &rest[position..];
|
||||
if let Some(link) = after.strip_prefix("\\orcidlink") {
|
||||
let trimmed = link.trim_start();
|
||||
if let Some((_, used)) = braced_group(trimmed) {
|
||||
out.push_str("iD ");
|
||||
rest = &trimmed[used..];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if let Some(graphic) = after.strip_prefix("\\includegraphics") {
|
||||
let mut tail = graphic.trim_start();
|
||||
if let Some(options) = tail.strip_prefix('[')
|
||||
&& let Some((_, rest)) = options.split_once(']')
|
||||
{
|
||||
tail = rest.trim_start();
|
||||
}
|
||||
if let Some((path, used)) = braced_group(tail)
|
||||
&& path.to_ascii_lowercase().contains("orcid")
|
||||
{
|
||||
out.push_str("iD ");
|
||||
rest = &tail[used..];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
out.push('\\');
|
||||
rest = &after[1..];
|
||||
}
|
||||
out.push_str(rest);
|
||||
out
|
||||
}
|
||||
|
||||
fn author_lines(author: &str) -> Vec<(String, bool)> {
|
||||
let mut lines = Vec::new();
|
||||
let mut starts_group = false;
|
||||
for row in author.split("\\\\") {
|
||||
let pieces: Vec<&str> = row.split("\\And").collect();
|
||||
for (index, piece) in pieces.iter().enumerate() {
|
||||
let text = clean_title_value(piece);
|
||||
let text = clean_title_value(&author_orcid_marker(piece));
|
||||
if text.is_empty() {
|
||||
continue;
|
||||
}
|
||||
@@ -19813,6 +19852,16 @@ left & right \\
|
||||
assert!(body.contains("Visible text."), "{body}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn orcid_graphics_become_id_markers() {
|
||||
let author = r"\href{https://orcid.org/0000}{\includegraphics[scale=0.06]{orcid.pdf}\hspace{1mm}Ada}";
|
||||
assert_eq!(
|
||||
author_orcid_marker(author),
|
||||
r"\href{https://orcid.org/0000}{iD \hspace{1mm}Ada}"
|
||||
);
|
||||
assert_eq!(author_orcid_marker(r"\orcidlink{0000-0002} Ada"), "iD Ada");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn arxiv_template_previews_without_warnings() {
|
||||
let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
|
||||
|
||||
Reference in new issue
Block a user