summaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-09-26 15:39:32 +0200
committerLaurenz <laurmaedje@gmail.com>2022-09-26 16:12:57 +0200
commit704f2fbaf1b4483caa12f249a222c49e44f08961 (patch)
tree146f7813fe63409df2c1bbaa487731e992d3ac71 /src/model
parent2661f1a5066bd5e3f8a9c68e4a5c304c248efcb7 (diff)
Description lists, link syntax, and new enum syntax
Diffstat (limited to 'src/model')
-rw-r--r--src/model/content.rs25
-rw-r--r--src/model/property.rs7
-rw-r--r--src/model/recipe.rs7
3 files changed, 20 insertions, 19 deletions
diff --git a/src/model/content.rs b/src/model/content.rs
index 92d592a6..ae074b50 100644
--- a/src/model/content.rs
+++ b/src/model/content.rs
@@ -14,7 +14,7 @@ use super::{
use crate::diag::StrResult;
use crate::library::layout::{FlowChild, FlowNode, PageNode, PlaceNode, Spacing};
use crate::library::prelude::*;
-use crate::library::structure::{DocNode, ListItem, ListNode, ORDERED, UNORDERED};
+use crate::library::structure::{DocNode, ListItem, ListNode, DESC, ENUM, LIST};
use crate::library::text::{
DecoNode, EmphNode, ParChild, ParNode, StrongNode, UNDERLINE,
};
@@ -62,7 +62,7 @@ pub enum Content {
/// A word space.
Space,
/// A forced line break.
- Linebreak { justified: bool },
+ Linebreak { justify: bool },
/// Horizontal spacing.
Horizontal { amount: Spacing, weak: bool },
/// Plain text.
@@ -264,7 +264,7 @@ impl Debug for Content {
match self {
Self::Empty => f.pad("Empty"),
Self::Space => f.pad("Space"),
- Self::Linebreak { justified } => write!(f, "Linebreak({justified})"),
+ Self::Linebreak { justify } => write!(f, "Linebreak({justify})"),
Self::Horizontal { amount, weak } => {
write!(f, "Horizontal({amount:?}, {weak})")
}
@@ -633,8 +633,8 @@ impl<'a> ParBuilder<'a> {
Content::Space => {
self.0.weak(ParChild::Text(' '.into()), styles, 2);
}
- &Content::Linebreak { justified } => {
- let c = if justified { '\u{2028}' } else { '\n' };
+ &Content::Linebreak { justify } => {
+ let c = if justify { '\u{2028}' } else { '\n' };
self.0.destructive(ParChild::Text(c.into()), styles);
}
&Content::Horizontal { amount, weak } => {
@@ -734,7 +734,7 @@ impl<'a> ListBuilder<'a> {
.items
.items()
.next()
- .map_or(true, |first| item.kind == first.kind) =>
+ .map_or(true, |first| item.kind() == first.kind()) =>
{
self.items.push(item.clone(), styles);
self.tight &= self.staged.drain(..).all(|(t, _)| *t != Content::Parbreak);
@@ -751,21 +751,16 @@ impl<'a> ListBuilder<'a> {
fn finish(self, parent: &mut Builder<'a>) -> SourceResult<()> {
let (items, shared) = self.items.finish();
let kind = match items.items().next() {
- Some(item) => item.kind,
+ Some(item) => item.kind(),
None => return Ok(()),
};
- let start = 1;
let tight = self.tight;
let attached = tight && self.attachable;
-
let content = match kind {
- UNORDERED => {
- Content::show(ListNode::<UNORDERED> { start, tight, attached, items })
- }
- ORDERED | _ => {
- Content::show(ListNode::<ORDERED> { start, tight, attached, items })
- }
+ LIST => Content::show(ListNode::<LIST> { tight, attached, items }),
+ ENUM => Content::show(ListNode::<ENUM> { tight, attached, items }),
+ DESC | _ => Content::show(ListNode::<DESC> { tight, attached, items }),
};
let stored = parent.scratch.templates.alloc(content);
diff --git a/src/model/property.rs b/src/model/property.rs
index 18f41eee..ab4f02e3 100644
--- a/src/model/property.rs
+++ b/src/model/property.rs
@@ -9,7 +9,7 @@ use super::{Interruption, NodeId, StyleChain};
use crate::eval::{RawLength, Smart};
use crate::geom::{Corners, Length, Numeric, Relative, Sides, Spec};
use crate::library::layout::PageNode;
-use crate::library::structure::{EnumNode, ListNode};
+use crate::library::structure::{DescNode, EnumNode, ListNode};
use crate::library::text::ParNode;
use crate::util::ReadableTypeId;
@@ -68,7 +68,10 @@ impl Property {
Some(Interruption::Page)
} else if self.is_of::<ParNode>() {
Some(Interruption::Par)
- } else if self.is_of::<ListNode>() || self.is_of::<EnumNode>() {
+ } else if self.is_of::<ListNode>()
+ || self.is_of::<EnumNode>()
+ || self.is_of::<DescNode>()
+ {
Some(Interruption::List)
} else {
None
diff --git a/src/model/recipe.rs b/src/model/recipe.rs
index 6b21ccf2..27b1be42 100644
--- a/src/model/recipe.rs
+++ b/src/model/recipe.rs
@@ -5,7 +5,7 @@ use comemo::Tracked;
use super::{Content, Interruption, NodeId, Show, ShowNode, StyleChain, StyleEntry};
use crate::diag::SourceResult;
use crate::eval::{Args, Func, Regex, Value};
-use crate::library::structure::{EnumNode, ListNode};
+use crate::library::structure::{DescNode, EnumNode, ListNode};
use crate::syntax::Spanned;
use crate::World;
@@ -93,7 +93,10 @@ impl Recipe {
/// What kind of structure the property interrupts.
pub fn interruption(&self) -> Option<Interruption> {
if let Pattern::Node(id) = self.pattern {
- if id == NodeId::of::<ListNode>() || id == NodeId::of::<EnumNode>() {
+ if id == NodeId::of::<ListNode>()
+ || id == NodeId::of::<EnumNode>()
+ || id == NodeId::of::<DescNode>()
+ {
return Some(Interruption::List);
}
}