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