Formatting 🛀
This commit is contained in:
parent
2ee5810fec
commit
a93b1ab003
@ -1,13 +1,13 @@
|
||||
use std::fs::{File, read_to_string};
|
||||
use std::io::BufWriter;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use futures_executor::block_on;
|
||||
|
||||
use typstc::Typesetter;
|
||||
use typstc::toddle::query::FileSystemFontProvider;
|
||||
use typstc::export::pdf::PdfExporter;
|
||||
|
||||
|
||||
fn main() {
|
||||
if let Err(err) = run() {
|
||||
eprintln!("error: {}", err);
|
||||
|
@ -22,6 +22,7 @@ use toddle::tables::{
|
||||
use crate::layout::{MultiLayout, Layout, LayoutAction};
|
||||
use crate::size::Size;
|
||||
|
||||
|
||||
/// Exports layouts into _PDFs_.
|
||||
pub struct PdfExporter {}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
//! Helper types and macros for creating custom functions.
|
||||
|
||||
|
||||
/// Defines function types concisely.
|
||||
#[macro_export]
|
||||
macro_rules! function {
|
||||
@ -121,6 +122,7 @@ macro_rules! function {
|
||||
'life1: 'async_trait,
|
||||
Self: 'async_trait,
|
||||
{
|
||||
#[allow(unreachable_code)]
|
||||
Box::pin(async move { Ok($code) })
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,8 @@
|
||||
use std::any::Any;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::{self, Debug, Formatter};
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
use self::prelude::*;
|
||||
|
||||
#[macro_use]
|
||||
|
@ -6,6 +6,7 @@ use toddle::query::FontIndex;
|
||||
use super::*;
|
||||
use LayoutAction::*;
|
||||
|
||||
|
||||
/// A layouting action.
|
||||
#[derive(Clone)]
|
||||
pub enum LayoutAction {
|
||||
|
@ -1,5 +1,6 @@
|
||||
use super::*;
|
||||
|
||||
|
||||
/// The line layouter arranges boxes next to each other along a primary axis
|
||||
/// and arranges the resulting lines using an underlying stack layouter.
|
||||
#[derive(Debug, Clone)]
|
||||
@ -181,7 +182,7 @@ impl LineLayouter {
|
||||
/// Finish the run and add secondary spacing to the underlying stack.
|
||||
pub fn add_secondary_spacing(
|
||||
&mut self,
|
||||
mut spacing: Size,
|
||||
spacing: Size,
|
||||
kind: SpacingKind
|
||||
) -> LayoutResult<()> {
|
||||
self.finish_line_if_not_empty()?;
|
||||
|
@ -39,6 +39,7 @@ pub use self::actions::{LayoutAction, LayoutActions};
|
||||
pub use self::layouters::*;
|
||||
pub use self::prelude::*;
|
||||
|
||||
|
||||
/// The result type for layouting.
|
||||
pub type LayoutResult<T> = crate::TypesetResult<T>;
|
||||
|
||||
|
@ -2,6 +2,7 @@ use smallvec::smallvec;
|
||||
use crate::size::ValueBox;
|
||||
use super::*;
|
||||
|
||||
|
||||
/// The stack layouter stack boxes onto each other along the secondary layouting
|
||||
/// axis.
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -5,6 +5,7 @@ use crate::size::{Size, Size2D};
|
||||
use crate::style::TextStyle;
|
||||
use super::*;
|
||||
|
||||
|
||||
/// The context for text layouting.
|
||||
///
|
||||
/// See [`LayoutContext`] for details about the fields.
|
||||
|
@ -4,7 +4,6 @@ use smallvec::smallvec;
|
||||
|
||||
use crate::func::Command;
|
||||
use crate::syntax::{SyntaxTree, Node, FuncCall};
|
||||
use crate::style::TextStyle;
|
||||
use super::*;
|
||||
|
||||
|
||||
@ -148,7 +147,7 @@ impl<'a, 'p> TreeLayouter<'a, 'p> {
|
||||
}
|
||||
SetAlignment(alignment) => self.ctx.alignment = alignment,
|
||||
SetAxes(axes) => {
|
||||
self.layouter.set_axes(axes);
|
||||
self.layouter.set_axes(axes)?;
|
||||
self.ctx.axes = axes;
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
//! format is _PDF_. Alternatively, the layout can be serialized to pass it to
|
||||
//! a suitable renderer.
|
||||
|
||||
#![allow(unused)]
|
||||
// #![allow(unused)]
|
||||
|
||||
pub extern crate toddle;
|
||||
|
||||
@ -42,6 +42,7 @@ pub mod syntax;
|
||||
pub mod size;
|
||||
pub mod style;
|
||||
|
||||
|
||||
/// Transforms source code into typesetted layouts.
|
||||
///
|
||||
/// A typesetter can be configured through various methods.
|
||||
|
@ -1,6 +1,7 @@
|
||||
use super::*;
|
||||
use AlignmentKey::*;
|
||||
|
||||
|
||||
/// An argument key which describes a target alignment.
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
|
||||
pub enum AlignmentKey {
|
||||
|
@ -1,6 +1,7 @@
|
||||
use super::*;
|
||||
use AxisKey::*;
|
||||
|
||||
|
||||
/// An argument key which identifies a layouting axis.
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
|
||||
pub enum AxisKey {
|
||||
|
@ -5,6 +5,7 @@ use std::hash::Hash;
|
||||
|
||||
use crate::func::prelude::*;
|
||||
|
||||
|
||||
macro_rules! key {
|
||||
($type:ty, $name:expr, $($patterns:tt)*) => {
|
||||
impl $type {
|
||||
|
@ -3,6 +3,7 @@ use AxisKey::*;
|
||||
use AlignmentKey::*;
|
||||
use PaddingKey::*;
|
||||
|
||||
|
||||
/// An argument key which identifies a margin or padding target.
|
||||
///
|
||||
/// A is the used axis type.
|
||||
|
@ -58,7 +58,7 @@ function! {
|
||||
list: Vec<String>,
|
||||
}
|
||||
|
||||
parse(args, body, ctx, meta) {
|
||||
parse(args, body, ctx) {
|
||||
FontFamilyFunc {
|
||||
body: parse!(optional: body, ctx),
|
||||
list: {
|
||||
@ -114,7 +114,7 @@ function! {
|
||||
weight: FontWeight,
|
||||
}
|
||||
|
||||
parse(args, body, ctx, meta) {
|
||||
parse(args, body, ctx) {
|
||||
FontWeightFunc {
|
||||
body: parse!(optional: body, ctx),
|
||||
weight: match args.get_pos::<Expression>()? {
|
||||
@ -195,7 +195,7 @@ function! {
|
||||
}
|
||||
}
|
||||
|
||||
layout(self, mut ctx) {
|
||||
layout(self, ctx) {
|
||||
let mut style = ctx.style.text.clone();
|
||||
match self.content {
|
||||
ContentKind::Word => style.word_spacing_scale = self.spacing,
|
||||
|
@ -1,5 +1,6 @@
|
||||
//! Auxiliary macros.
|
||||
|
||||
|
||||
/// Create trait implementations for an error type.
|
||||
macro_rules! error_type {
|
||||
(
|
||||
@ -36,16 +37,6 @@ macro_rules! error_type {
|
||||
};
|
||||
}
|
||||
|
||||
/// Shorthand for checking whether an expression matches a pattern.
|
||||
macro_rules! matches {
|
||||
($expr:expr, $($pattern:tt)*) => {
|
||||
match $expr {
|
||||
$($pattern)* => true,
|
||||
_ => false,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// Create a `Debug` implementation from a `Display` implementation.
|
||||
macro_rules! debug_display {
|
||||
($type:ident) => (
|
||||
|
@ -7,6 +7,7 @@ use std::str::FromStr;
|
||||
|
||||
use crate::layout::prelude::*;
|
||||
|
||||
|
||||
/// A general spacing type.
|
||||
#[derive(Default, Copy, Clone, PartialEq, PartialOrd)]
|
||||
pub struct Size {
|
||||
|
@ -10,6 +10,7 @@ pub_use_mod!(tokens);
|
||||
pub_use_mod!(parsing);
|
||||
pub_use_mod!(span);
|
||||
|
||||
|
||||
/// A logical unit of the incoming text stream.
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
pub enum Token<'s> {
|
||||
|
@ -4,6 +4,7 @@ use crate::func::Scope;
|
||||
use crate::size::Size;
|
||||
use super::*;
|
||||
|
||||
|
||||
/// The result type for parsing.
|
||||
pub type ParseResult<T> = crate::TypesetResult<T>;
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
use std::fmt::{self, Display, Formatter};
|
||||
|
||||
|
||||
/// Annotates a value with the part of the source code it corresponds to.
|
||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||
pub struct Spanned<T> {
|
||||
|
@ -5,6 +5,7 @@ use smallvec::SmallVec;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
||||
/// Builds an iterator over the tokens of the source code.
|
||||
pub fn tokenize(src: &str) -> Tokens {
|
||||
Tokens::new(src)
|
||||
|
Loading…
x
Reference in New Issue
Block a user