Render ORCID author links as green badges

This commit is contained in:
gloamxun committed 2026-10-19 19:01:12 +08:00
1 parent 7c4edbb1f1
commit d9befd4d87
5 files changed
+38 -14

No files matched your search

+5 -4
View File
@@ -107,10 +107,11 @@ See `docs/ROADMAP.md` for concrete implementation plans.
the next page.
- Contents: chapter headings are listed with chapter-prefixed section
numbers, but contents are not split per chapter.
- Preprint title blocks: ORCID icons embedded in `\author` are dropped because
metadata does not carry images. Hyperlinks use hyperref's green text colour;
PDF link annotations are not emitted. Title-block vertical spacing is tighter
than the reference class.
- Preprint title blocks: ORCID links in `\author` render as a green `iD`
badge before the author name; the bitmap ORCID icon itself is not embedded.
Hyperlinks use hyperref's green text colour; PDF link annotations are not
emitted. Metadata baselines match the reference within 0.3 pt, but page 1
can lose one body line compared with the reference.
## Verification
+2 -1
View File
@@ -74,7 +74,8 @@ const PRELUDE: &str = r#"
\def\nocite#1{}
\def\newblock{ }
\def\caption#1{\texrracaptionstart#1\texrracaptionend}
\def\href#1#2{\texrrahref{#2}}
\def\href#1#2{\texrrahref{#1}{#2}}
\def\texrraorcibadge{iD\ }
\def\hline{\texrratablerule}
\def\toprule{\texrratablerule}
\def\midrule{\texrratablerule}
+18 -6
View File
@@ -1901,15 +1901,27 @@ pub(super) fn build_positioned_pages(
for lines in &blocks {
let mut measured_lines = Vec::with_capacity(lines.len());
for (index, text) in lines.iter().enumerate() {
let mut run = Run::plain(text.clone());
if index == 0 {
run.bold = true;
let mut runs = Vec::new();
let mut rest = text.as_str();
if let Some(after_badge) = text.strip_prefix("iD ") {
let mut badge = Run::plain("iD ".to_string());
badge.bold = true;
badge.link = true;
runs.push(badge);
rest = after_badge;
}
if text.contains('@') && !text.contains(' ') {
run.monospace = true;
if !rest.is_empty() {
let mut run = Run::plain(rest.to_string());
if index == 0 {
run.bold = true;
}
if rest.contains('@') && !rest.contains(' ') {
run.monospace = true;
}
runs.push(run);
}
if let Some(line) = measure_positioned_lines(
&[run],
&runs,
base_font_size,
column_width - 2.0,
metrics,
+9 -3
View File
@@ -3661,13 +3661,19 @@ fn href_primitive(
token: token::Token,
input: &mut vm::ExecutionInput<CompilerState>,
) -> texlang::prelude::Result<()> {
// The prelude macro consumes the URL argument; this primitive only sees the
// visible link text, which is wrapped in a link span for hyperref colour.
let url = read_unexpanded_argument(input, token, "expects a link URL")?;
let content = read_unexpanded_argument(input, token, "expects link text")?;
let inner = strip_braced_tokens(&content).to_vec();
write_event(input, token, FrontendEventKind::LinkStart);
let trace_key = token.trace_key();
let mut expansion = inner;
let mut expansion = Vec::new();
if simple_token_text(&url)
.to_ascii_lowercase()
.contains("orcid.org")
{
expansion.push(control_sequence_token(input, "texrraorcibadge", trace_key));
}
expansion.extend(inner);
expansion.push(control_sequence_token(input, "texrralinkend", trace_key));
input
.as_mut()
+4
View File
@@ -133,6 +133,10 @@ fn arxiv_title_block_uses_rules_and_small_caps() {
first_page.contains("font-style=\"italic\">arxiv</text>"),
"italic emph{{arxiv}} title run missing"
);
assert!(
first_page.contains("fill=\"#008000\">iD</text>"),
"ORCID link badge missing"
);
}
#[test]