Annotate ORCID author badges with their profile links
This commit is contained in:
1 parent
05d7980561
commit
2076da8f21
8 files changed
+52
-10
No files matched your search
@@ -528,7 +528,7 @@ advisory breaks, starred `\vspace`/`\hspace`, `center`, `\hrule`, `\fbox`,
|
||||
| Notes/floats | footnotes with page-bottom insertion area, title/author `\thanks`, figure `[htbp]` placement (deferred top floats, bottom/page/here), table `[t]`/`[b]`/`[p]` placement | table float-page queues, `\textfraction` |
|
||||
| Contents | `\tableofcontents`, `\listoffigures`, `\listoftables` generated from numbered headings and captions, dotted leaders, page numbers resolved after pagination | per-chapter book/report contents |
|
||||
| Pages | A4/Letter/... page sizes, margins/geometry, automatic pagination, `\newpage`, `\pagebreak`, plain/fancy page styles, `\thispagestyle`, fancyhdr L/C/R headers and footers | — |
|
||||
| Links | `\href`, `\url`, hyperref-green link text, `\orcidlink{id}` green `iD` badge | PDF `/Annots` URI annotations |
|
||||
| Links | `\href`, `\url`, hyperref-green link text, `\orcidlink{id}` green `iD` badge, clickable PDF `/Annots` URI annotations for visible URLs, `\href` labels, and ORCID author badges | — |
|
||||
| Classes/packages | built-in + local classes, option protocol, local package options, base font sizes 10/11/12pt, chapter headings and numbering, chapter page breaks, document-level custom `\maketitle`, native arxiv-style preprint title blocks (rules, `\undertitle`, author columns, long date) | class-specific formatting beyond chapter breaks |
|
||||
| Live preview | incremental paragraph cache, page-hash diffing, SVG refresh | — |
|
||||
|
||||
|
||||
@@ -101,6 +101,7 @@ pub struct DocumentModel {
|
||||
pub citation_metadata: HashMap<String, CitationMetadata>,
|
||||
/// Display text -> hyperlink URL for `\href` annotations.
|
||||
pub link_targets: HashMap<String, String>,
|
||||
pub orcid_urls: Vec<String>,
|
||||
/// Bibliography keys in the order their metadata was declared. Needed to
|
||||
/// assign natbib-style year suffixes (2014a, 2014b, ...) deterministically.
|
||||
pub bibliography_order: Vec<String>,
|
||||
@@ -131,6 +132,7 @@ impl Default for DocumentModel {
|
||||
citations: HashMap::new(),
|
||||
citation_metadata: HashMap::new(),
|
||||
link_targets: HashMap::new(),
|
||||
orcid_urls: Vec::new(),
|
||||
bibliography_order: Vec::new(),
|
||||
author_year_citations: false,
|
||||
footnotes: Vec::new(),
|
||||
|
||||
@@ -1156,6 +1156,9 @@ impl Parser {
|
||||
self.link_depth = self.link_depth.saturating_add(1);
|
||||
}
|
||||
expanded::FrontendEventKind::LinkTarget { text, url } => {
|
||||
if url.contains("orcid.org") {
|
||||
self.document.orcid_urls.push(url.clone());
|
||||
}
|
||||
self.document.link_targets.insert(text.clone(), url.clone());
|
||||
}
|
||||
expanded::FrontendEventKind::LinkEnd => {
|
||||
|
||||
+7
-7
@@ -111,9 +111,9 @@ See `docs/ROADMAP.md` for concrete implementation plans.
|
||||
badge (rounded ORCID-green polygon with a white iD, drawn natively in PDF
|
||||
and SVG) before the author name; the original bitmap ORCID logo is not
|
||||
embedded.
|
||||
Hyperlinks use hyperref's green text colour; visible `\url` text emits a
|
||||
PDF `/Link` URI annotation (`/Annots`). `\href`/ORCID-name labels still
|
||||
carry only colour, because their target URL is not yet stored on the run.
|
||||
Hyperlinks use hyperref's green text colour; visible `\url` text,
|
||||
`\href` display labels, and ORCID author badges emit PDF `/Link` URI
|
||||
annotations (`/Annots`).
|
||||
Metadata baselines match the reference within 0.3 pt and page 1 keeps the
|
||||
same closing section-2 line as the reference. `printpdf 0.3.4` has no
|
||||
annotation API, so the link is added by reopening the finished PDF with
|
||||
@@ -128,7 +128,7 @@ See `docs/ROADMAP.md` for concrete implementation plans.
|
||||
3.6 MB and `pdffonts` reports only embedded CID TrueType faces); this avoids
|
||||
viewer-dependent glyph substitution. Tables use natural column widths and
|
||||
centered rules; preview and PDF share the same table line coordinates.
|
||||
- `cargo fmt --check` passes; `cargo test --offline` (54 tests: 50 compiler
|
||||
- `cargo fmt --check` passes; `cargo test --offline` (56 tests: 52 compiler
|
||||
integration tests + 4 server tests) covers the three examples, the arXiv
|
||||
fixture, figure/table floats (top and bottom), newpage, page styles and `\thispagestyle`, SVG/PDF output,
|
||||
project API, static frontend assets, path traversal, the legacy
|
||||
@@ -137,7 +137,7 @@ See `docs/ROADMAP.md` for concrete implementation plans.
|
||||
|
||||
## Verification snapshot
|
||||
|
||||
- Compiler integration tests: 50; server tests: 4; total 54.
|
||||
- Compiler integration tests: 52; server tests: 4; total 56.
|
||||
- `cargo fmt --check` passes.
|
||||
- arXiv fixture: 3 Letter pages, ~3.6 MB, embedded Liberation faces only.
|
||||
- Title/author/date/Introduction baselines within 0.3 pt of the XeLaTeX
|
||||
@@ -145,5 +145,5 @@ See `docs/ROADMAP.md` for concrete implementation plans.
|
||||
- Table 61.1 mm wide (reference 61.2 mm) with `\multicolumn` spans and
|
||||
partial `\cmidrule` rules; table rules in the SVG preview use absolute page
|
||||
coordinates, matching the PDF.
|
||||
- Remaining blocker: PDF link annotations (`/Annots`); printpdf 0.3.4 has
|
||||
no annotation API, so clickable `\href`/`\url` need a writer extension.
|
||||
- PDF link annotations are added by reopening the finished PDF with lopdf,
|
||||
since printpdf 0.3.4 has no annotation API.
|
||||
+15
-1
@@ -361,6 +361,7 @@ enum PositionedPageItem {
|
||||
Badge {
|
||||
x: i64,
|
||||
y: i64,
|
||||
url: Option<String>,
|
||||
},
|
||||
FramedBox {
|
||||
anchor: PageAnchor,
|
||||
@@ -580,6 +581,19 @@ impl PositionedPages {
|
||||
link_targets,
|
||||
);
|
||||
}
|
||||
PositionedPageItem::Badge {
|
||||
x,
|
||||
y,
|
||||
url: Some(url),
|
||||
} => {
|
||||
let left = scaled_units_to_mm(*x);
|
||||
let bottom = page_height_mm - (scaled_units_to_mm(*y) + 4.0);
|
||||
annotations.push(LinkAnnotation {
|
||||
page: index as u32 + 1,
|
||||
rect: [left, bottom, left + 4.0, bottom + 4.0],
|
||||
url: url.clone(),
|
||||
});
|
||||
}
|
||||
PositionedPageItem::Centered { element, y, .. } => {
|
||||
let font_size = 11;
|
||||
let em = f64::from(font_size) * 25.4 / 72.27;
|
||||
@@ -791,7 +805,7 @@ impl Element for PositionedPages {
|
||||
y,
|
||||
)
|
||||
}
|
||||
PositionedPageItem::Badge { x, y } => {
|
||||
PositionedPageItem::Badge { x, y, .. } => {
|
||||
let x = scaled_units_to_mm(*x);
|
||||
let y = scaled_units_to_mm(*y);
|
||||
let mut badge_area = body_area.clone();
|
||||
|
||||
@@ -2023,6 +2023,7 @@ pub(super) fn build_positioned_pages(
|
||||
.push(PositionedPageItem::Badge {
|
||||
x: millimeters_to_scaled(line_x),
|
||||
y: badge_y,
|
||||
url: model.orcid_urls.get(column).cloned(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ fn page_svg(
|
||||
monospace_family,
|
||||
sans_family,
|
||||
),
|
||||
PositionedPageItem::Badge { x, y } => write_badge(&mut output, *x, *y),
|
||||
PositionedPageItem::Badge { x, y, .. } => write_badge(&mut output, *x, *y),
|
||||
PositionedPageItem::Image { element, y, .. } => write_figure(
|
||||
&mut output,
|
||||
element,
|
||||
|
||||
@@ -88,6 +88,28 @@ fn hello_compiles_to_pdf() {
|
||||
|
||||
#[test]
|
||||
|
||||
fn arxiv_author_orcid_links_have_pdf_annotations() {
|
||||
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("fixtures")
|
||||
.join("arxiv-template")
|
||||
.join("template.tex");
|
||||
let source = std::fs::read_to_string(&path).expect("read arXiv fixture");
|
||||
let file_name = path.to_string_lossy().to_string();
|
||||
let pdf = CompilerSession::default()
|
||||
.compile(&source, &file_name)
|
||||
.expect("arXiv PDF");
|
||||
let text = String::from_utf8_lossy(&pdf);
|
||||
assert!(
|
||||
text.contains("/Subtype/Link"),
|
||||
"ORCID links should be annotations"
|
||||
);
|
||||
assert!(
|
||||
text.contains("orcid.org/0000-0000-0000-0000"),
|
||||
"annotation should carry the ORCID URL"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn arxiv_fixture_is_three_letter_pages() {
|
||||
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("fixtures")
|
||||
|
||||
Reference in new issue
Block a user