pub struct AutoNumber {
pub number_headings: bool,
pub per_chapter: bool,
/* private fields */
}Expand description
Walks the AST and assigns sequential numbers to figures, tables, listings, theorem-group components, definition-group components, display math equations, and headings.
Numbers are injected as a number string attribute on Component nodes.
For MathDisplay nodes (which are not components), the numbers are only
stored in the registry.
After calling Transform::transform, retrieve the full registry via
AutoNumber::registry.
§Example
use rdx_transform::{AutoNumber, Transform, parse};
let mut root = parse("<Figure id=\"fig:arch\">\n</Figure>\n");
let numberer = AutoNumber::new();
numberer.transform(&mut root, "");
let reg = numberer.registry();
assert_eq!(reg.entries["fig:arch"].number, "1");Fields§
§number_headings: boolIf true, number headings hierarchically (1, 1.1, 1.1.2).
per_chapter: boolIf true, prefix figure/table numbers with chapter (Figure 2.3 vs Figure 7). When enabled, the chapter counter is the h1 section counter.
Implementations§
Source§impl AutoNumber
impl AutoNumber
pub fn new() -> Self
Sourcepub fn registry(&self) -> Ref<'_, NumberRegistry>
pub fn registry(&self) -> Ref<'_, NumberRegistry>
Return a shared borrow of the registry built during the last call to
Transform::transform.
§Panics
Panics if the registry is already mutably borrowed elsewhere. This should never happen because transforms run single-threaded.
Trait Implementations§
Source§impl Default for AutoNumber
impl Default for AutoNumber
Source§impl Transform for AutoNumber
impl Transform for AutoNumber
Auto Trait Implementations§
impl !Freeze for AutoNumber
impl !RefUnwindSafe for AutoNumber
impl Send for AutoNumber
impl !Sync for AutoNumber
impl Unpin for AutoNumber
impl UnsafeUnpin for AutoNumber
impl UnwindSafe for AutoNumber
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.