Render hyperlinks with hyperref green colour
This commit is contained in:
1 parent
a8b20563fb
commit
09781d40e9
12 files changed
+158
-11
No files matched your search
@@ -201,6 +201,10 @@ pub struct PageStyleOverride {
|
||||
/// Marker character used by `\thepage` inside header/footer runs; the page
|
||||
/// renderer substitutes the concrete page number before measuring and painting.
|
||||
/// Private-use marker for a dotted leader in generated contents lines.
|
||||
/// Private-use marker toggling hyperlink paint for the following glyphs.
|
||||
pub const LINK_START_MARKER: char = '\u{F3000}';
|
||||
pub const LINK_END_MARKER: char = '\u{F3001}';
|
||||
|
||||
pub const CONTENTS_LEADER_MARKER: char = '\u{F6000}';
|
||||
|
||||
pub const PAGE_NUMBER_MARKER: char = '\u{F5000}';
|
||||
@@ -413,6 +417,8 @@ pub struct Run {
|
||||
pub monospace: bool,
|
||||
pub sans: bool,
|
||||
pub small_caps: bool,
|
||||
/// Hyperlink text (rendered in the hyperref link colour).
|
||||
pub link: bool,
|
||||
/// True for the synthetic kern that carries paragraph indentation.
|
||||
pub paragraph_indent: bool,
|
||||
/// Alignment declaration active when this run started its paragraph.
|
||||
@@ -437,6 +443,7 @@ impl Run {
|
||||
monospace: false,
|
||||
sans: false,
|
||||
small_caps: false,
|
||||
link: false,
|
||||
paragraph_indent: false,
|
||||
alignment: None,
|
||||
}
|
||||
|
||||
@@ -464,6 +464,7 @@ struct Parser {
|
||||
text_style_stack: Vec<(expanded::TextStyle, bool, bool, bool, bool, bool)>,
|
||||
style_declarations: Vec<(usize, expanded::TextStyle)>,
|
||||
group_depth: usize,
|
||||
link_depth: usize,
|
||||
section_numbers: [u32; 4],
|
||||
has_chapters: bool,
|
||||
equation_number: u32,
|
||||
@@ -575,6 +576,7 @@ impl Parser {
|
||||
text_style_stack: Vec::new(),
|
||||
style_declarations: Vec::new(),
|
||||
group_depth: 0,
|
||||
link_depth: 0,
|
||||
section_numbers: [0; 4],
|
||||
has_chapters: false,
|
||||
equation_number: 0,
|
||||
@@ -885,6 +887,7 @@ impl Parser {
|
||||
monospace,
|
||||
sans,
|
||||
small_caps,
|
||||
link: self.link_depth > 0,
|
||||
paragraph_indent: false,
|
||||
alignment: None,
|
||||
};
|
||||
@@ -932,6 +935,7 @@ impl Parser {
|
||||
|
||||
sans: false,
|
||||
small_caps: false,
|
||||
link: false,
|
||||
|
||||
y_offset: None,
|
||||
|
||||
@@ -1148,6 +1152,12 @@ impl Parser {
|
||||
}
|
||||
expanded::FrontendEventKind::LiteralAmpersand
|
||||
| expanded::FrontendEventKind::MathCell => self.append_literal_ampersand(),
|
||||
expanded::FrontendEventKind::LinkStart => {
|
||||
self.link_depth = self.link_depth.saturating_add(1);
|
||||
}
|
||||
expanded::FrontendEventKind::LinkEnd => {
|
||||
self.link_depth = self.link_depth.saturating_sub(1);
|
||||
}
|
||||
expanded::FrontendEventKind::LiteralCharacter(character) => {
|
||||
self.append_text(&character.to_string())
|
||||
}
|
||||
@@ -1410,6 +1420,7 @@ impl Parser {
|
||||
|
||||
sans: false,
|
||||
small_caps: false,
|
||||
link: false,
|
||||
|
||||
y_offset: None,
|
||||
|
||||
@@ -1503,6 +1514,7 @@ impl Parser {
|
||||
let monospace = self.monospace;
|
||||
let sans = self.sans;
|
||||
let small_caps = self.small_caps;
|
||||
let link = self.link_depth > 0;
|
||||
if self.table.is_some() {
|
||||
let mut pieces = text.split('&').peekable();
|
||||
while let Some(piece) = pieces.next() {
|
||||
@@ -1514,6 +1526,7 @@ impl Parser {
|
||||
monospace,
|
||||
sans,
|
||||
small_caps,
|
||||
link,
|
||||
);
|
||||
if pieces.peek().is_some() {
|
||||
self.finish_table_cell();
|
||||
@@ -1528,6 +1541,7 @@ impl Parser {
|
||||
monospace,
|
||||
sans,
|
||||
small_caps,
|
||||
link,
|
||||
);
|
||||
}
|
||||
let alignment = self.paragraph_alignment;
|
||||
@@ -1576,6 +1590,7 @@ impl Parser {
|
||||
|
||||
sans: false,
|
||||
small_caps: false,
|
||||
link: false,
|
||||
|
||||
y_offset: None,
|
||||
|
||||
@@ -1614,6 +1629,7 @@ impl Parser {
|
||||
|
||||
sans: false,
|
||||
small_caps: false,
|
||||
link: false,
|
||||
|
||||
y_offset: None,
|
||||
|
||||
@@ -1657,6 +1673,7 @@ impl Parser {
|
||||
|
||||
sans: false,
|
||||
small_caps: false,
|
||||
link: false,
|
||||
|
||||
y_offset: None,
|
||||
|
||||
@@ -1710,6 +1727,7 @@ impl Parser {
|
||||
|
||||
sans: false,
|
||||
small_caps: false,
|
||||
link: false,
|
||||
|
||||
y_offset: None,
|
||||
|
||||
@@ -1804,6 +1822,7 @@ impl Parser {
|
||||
let monospace = self.monospace;
|
||||
let sans = self.sans;
|
||||
let small_caps = self.small_caps;
|
||||
let link = self.link_depth > 0;
|
||||
append_run(
|
||||
self.target_runs(),
|
||||
"&".to_string(),
|
||||
@@ -1812,6 +1831,7 @@ impl Parser {
|
||||
monospace,
|
||||
sans,
|
||||
small_caps,
|
||||
link,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1850,6 +1870,7 @@ impl Parser {
|
||||
|
||||
sans: false,
|
||||
small_caps: false,
|
||||
link: true,
|
||||
|
||||
y_offset: None,
|
||||
|
||||
@@ -2368,6 +2389,7 @@ fn indent_run(indent: common::Scaled) -> Run {
|
||||
monospace: false,
|
||||
sans: false,
|
||||
small_caps: false,
|
||||
link: false,
|
||||
y_offset: None,
|
||||
footnote_number: None,
|
||||
paragraph_indent: true,
|
||||
@@ -2415,6 +2437,7 @@ fn append_run(
|
||||
monospace: bool,
|
||||
sans: bool,
|
||||
small_caps: bool,
|
||||
link: bool,
|
||||
) {
|
||||
if text.is_empty() {
|
||||
return;
|
||||
@@ -2438,6 +2461,7 @@ fn append_run(
|
||||
&& last.monospace == monospace
|
||||
&& last.sans == sans
|
||||
&& last.small_caps == small_caps
|
||||
&& last.link == link
|
||||
{
|
||||
last.text.push_str(&text);
|
||||
return;
|
||||
@@ -2456,6 +2480,7 @@ fn append_run(
|
||||
monospace,
|
||||
sans,
|
||||
small_caps,
|
||||
link,
|
||||
paragraph_indent: false,
|
||||
alignment: None,
|
||||
|
||||
|
||||
@@ -264,6 +264,10 @@ pub enum FrontendEventKind {
|
||||
header: bool,
|
||||
},
|
||||
PageNumber,
|
||||
/// Start of hyperlink material.
|
||||
LinkStart,
|
||||
/// End of hyperlink material.
|
||||
LinkEnd,
|
||||
/// A package or class was loaded from a local file.
|
||||
PackageLoaded(String),
|
||||
/// A separator between author blocks (LaTeX's \And).
|
||||
|
||||
Reference in new issue
Block a user