mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Do as Dolores says ⚡
This commit is contained in:
parent
37835e4d8e
commit
2a92428ff6
@ -132,9 +132,7 @@ impl PartialEq for Value {
|
|||||||
(Color(a), Color(b)) => a == b,
|
(Color(a), Color(b)) => a == b,
|
||||||
(Table(a), Table(b)) => a == b,
|
(Table(a), Table(b)) => a == b,
|
||||||
(Tree(a), Tree(b)) => a == b,
|
(Tree(a), Tree(b)) => a == b,
|
||||||
(Func(a), Func(b)) => {
|
(Func(a), Func(b)) => Rc::ptr_eq(a, b),
|
||||||
a.as_ref() as *const _ == b.as_ref() as *const _
|
|
||||||
}
|
|
||||||
(Commands(a), Commands(b)) => a == b,
|
(Commands(a), Commands(b)) => a == b,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
@ -202,7 +200,7 @@ impl TableValue {
|
|||||||
/// there is any.
|
/// there is any.
|
||||||
///
|
///
|
||||||
/// Generates an error if the key exists but the value does not match.
|
/// Generates an error if the key exists but the value does not match.
|
||||||
pub fn take_key<'a, T>(&mut self, key: &str, f: &mut Feedback) -> Option<T>
|
pub fn take_key<T>(&mut self, key: &str, f: &mut Feedback) -> Option<T>
|
||||||
where
|
where
|
||||||
T: TryFromValue,
|
T: TryFromValue,
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ use tide::{PdfWriter, Rect, Ref, Trailer, Version};
|
|||||||
use ttf_parser::{name_id, GlyphId};
|
use ttf_parser::{name_id, GlyphId};
|
||||||
|
|
||||||
use crate::layout::elements::LayoutElement;
|
use crate::layout::elements::LayoutElement;
|
||||||
use crate::layout::{BoxLayout, MultiLayout};
|
use crate::layout::BoxLayout;
|
||||||
use crate::length::Length;
|
use crate::length::Length;
|
||||||
use crate::SharedFontLoader;
|
use crate::SharedFontLoader;
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ use crate::SharedFontLoader;
|
|||||||
/// The raw _PDF_ is written into the `target` writable, returning the number of
|
/// The raw _PDF_ is written into the `target` writable, returning the number of
|
||||||
/// bytes written.
|
/// bytes written.
|
||||||
pub fn export<W: Write>(
|
pub fn export<W: Write>(
|
||||||
layout: &MultiLayout,
|
layout: &[BoxLayout],
|
||||||
loader: &SharedFontLoader,
|
loader: &SharedFontLoader,
|
||||||
target: W,
|
target: W,
|
||||||
) -> io::Result<usize> {
|
) -> io::Result<usize> {
|
||||||
@ -36,7 +36,7 @@ pub fn export<W: Write>(
|
|||||||
|
|
||||||
struct PdfExporter<'a, W: Write> {
|
struct PdfExporter<'a, W: Write> {
|
||||||
writer: PdfWriter<W>,
|
writer: PdfWriter<W>,
|
||||||
layouts: &'a MultiLayout,
|
layouts: &'a [BoxLayout],
|
||||||
loader: &'a SharedFontLoader,
|
loader: &'a SharedFontLoader,
|
||||||
/// We need to know exactly which indirect reference id will be used for
|
/// We need to know exactly which indirect reference id will be used for
|
||||||
/// which objects up-front to correctly declare the document catalogue, page
|
/// which objects up-front to correctly declare the document catalogue, page
|
||||||
@ -60,7 +60,7 @@ const NUM_OBJECTS_PER_FONT: u32 = 5;
|
|||||||
|
|
||||||
impl<'a, W: Write> PdfExporter<'a, W> {
|
impl<'a, W: Write> PdfExporter<'a, W> {
|
||||||
fn new(
|
fn new(
|
||||||
layouts: &'a MultiLayout,
|
layouts: &'a [BoxLayout],
|
||||||
loader: &'a SharedFontLoader,
|
loader: &'a SharedFontLoader,
|
||||||
target: W,
|
target: W,
|
||||||
) -> io::Result<Self> {
|
) -> io::Result<Self> {
|
||||||
@ -289,7 +289,7 @@ impl<'a, W: Write> PdfExporter<'a, W> {
|
|||||||
/// Assigns a new PDF-internal index to each used face and returns two mappings:
|
/// Assigns a new PDF-internal index to each used face and returns two mappings:
|
||||||
/// - Forwards from the old face ids to the new pdf indices (hash map)
|
/// - Forwards from the old face ids to the new pdf indices (hash map)
|
||||||
/// - Backwards from the pdf indices to the old face ids (vec)
|
/// - Backwards from the pdf indices to the old face ids (vec)
|
||||||
fn remap_fonts(layouts: &MultiLayout) -> (HashMap<FaceId, usize>, Vec<FaceId>) {
|
fn remap_fonts(layouts: &[BoxLayout]) -> (HashMap<FaceId, usize>, Vec<FaceId>) {
|
||||||
let mut to_pdf = HashMap::new();
|
let mut to_pdf = HashMap::new();
|
||||||
let mut to_layout = vec![];
|
let mut to_layout = vec![];
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ impl Parser<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Token::LeftBracket => {
|
Token::LeftBracket => {
|
||||||
self.parse_bracket_call(false).map(|c| SyntaxNode::Call(c))
|
self.parse_bracket_call(false).map(SyntaxNode::Call)
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Star => self.with_span(SyntaxNode::ToggleBolder),
|
Token::Star => self.with_span(SyntaxNode::ToggleBolder),
|
||||||
@ -143,7 +143,7 @@ impl Parser<'_> {
|
|||||||
let (has_chained_child, end) = if self.peek().is_some() {
|
let (has_chained_child, end) = if self.peek().is_some() {
|
||||||
let item = self.parse_bracket_call(true);
|
let item = self.parse_bracket_call(true);
|
||||||
let span = item.span;
|
let span = item.span;
|
||||||
let t = vec![item.map(|f| SyntaxNode::Call(f))];
|
let t = vec![item.map(SyntaxNode::Call)];
|
||||||
args.push(SpannedEntry::val(Spanned::new(Expr::Tree(t), span)));
|
args.push(SpannedEntry::val(Spanned::new(Expr::Tree(t), span)));
|
||||||
(true, span.end)
|
(true, span.end)
|
||||||
} else {
|
} else {
|
||||||
@ -203,10 +203,10 @@ impl Parser<'_> {
|
|||||||
|
|
||||||
Some(Token::LeftParen) => {
|
Some(Token::LeftParen) => {
|
||||||
let call = self.parse_paren_call(ident);
|
let call = self.parse_paren_call(ident);
|
||||||
(None, call.map(|c| Expr::Call(c)))
|
(None, call.map(Expr::Call))
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => (None, ident.map(|id| Expr::Ident(id)))
|
_ => (None, ident.map(Expr::Ident))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(None, try_or!(self.parse_expr(), {
|
(None, try_or!(self.parse_expr(), {
|
||||||
@ -316,9 +316,9 @@ impl Parser<'_> {
|
|||||||
self.eat();
|
self.eat();
|
||||||
self.skip_white();
|
self.skip_white();
|
||||||
if self.check(Token::LeftParen) {
|
if self.check(Token::LeftParen) {
|
||||||
self.parse_paren_call(name).map(|call| Expr::Call(call))
|
self.parse_paren_call(name).map(Expr::Call)
|
||||||
} else {
|
} else {
|
||||||
name.map(|id| Expr::Ident(id))
|
name.map(Expr::Ident)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,7 +377,7 @@ impl Parser<'_> {
|
|||||||
// This is a bracketed function call.
|
// This is a bracketed function call.
|
||||||
Token::LeftBracket => {
|
Token::LeftBracket => {
|
||||||
let call = self.parse_bracket_call(false);
|
let call = self.parse_bracket_call(false);
|
||||||
let tree = vec![call.map(|c| SyntaxNode::Call(c))];
|
let tree = vec![call.map(SyntaxNode::Call)];
|
||||||
Spanned::new(Expr::Tree(tree), span)
|
Spanned::new(Expr::Tree(tree), span)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,7 +478,7 @@ pub fn is_identifier(string: &str) -> bool {
|
|||||||
_ => return false,
|
_ => return false,
|
||||||
}
|
}
|
||||||
|
|
||||||
while let Some(c) = chars.next() {
|
for c in chars {
|
||||||
match c {
|
match c {
|
||||||
c if UnicodeXID::is_xid_continue(c) || is_extra_allowed(c) => {}
|
c if UnicodeXID::is_xid_continue(c) || is_extra_allowed(c) => {}
|
||||||
_ => return false,
|
_ => return false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user