pub struct TransformPipeline { /* private fields */ }Expand description
Builder for creating transformation pipelines
Allows chaining multiple transformations together with conditional logic.
§Example
use markdown_ppp::ast::*;
use markdown_ppp::ast_transform::TransformPipeline;
let doc = Document {
blocks: vec![Block::Paragraph(vec![Inline::Text(" hello ".to_string())])],
};
let result = TransformPipeline::new()
.transform_text(|s| s.trim().to_string())
.transform_image_urls(|url| format!("https://cdn.example.com{}", url))
.apply(doc);Implementations§
Source§impl TransformPipeline
impl TransformPipeline
Sourcepub fn transform_text<F>(self, f: F) -> Self
pub fn transform_text<F>(self, f: F) -> Self
Transform all text elements
Sourcepub fn transform_image_urls<F>(self, f: F) -> Self
pub fn transform_image_urls<F>(self, f: F) -> Self
Transform all image URLs
Sourcepub fn transform_link_urls<F>(self, f: F) -> Self
pub fn transform_link_urls<F>(self, f: F) -> Self
Transform all link URLs
Sourcepub fn transform_autolink_urls<F>(self, f: F) -> Self
pub fn transform_autolink_urls<F>(self, f: F) -> Self
Transform all autolink URLs
Sourcepub fn transform_code<F>(self, f: F) -> Self
pub fn transform_code<F>(self, f: F) -> Self
Transform all code spans
Sourcepub fn transform_html<F>(self, f: F) -> Self
pub fn transform_html<F>(self, f: F) -> Self
Transform all HTML content
Sourcepub fn transform_with<T: Transformer + 'static>(self, transformer: T) -> Self
pub fn transform_with<T: Transformer + 'static>(self, transformer: T) -> Self
Apply a custom transformer
Sourcepub fn when_doc<P, F>(self, predicate: P, builder: F) -> Selfwhere
P: Fn(&Document) -> bool + 'static,
F: FnOnce(TransformPipeline) -> TransformPipeline + 'static,
pub fn when_doc<P, F>(self, predicate: P, builder: F) -> Selfwhere
P: Fn(&Document) -> bool + 'static,
F: FnOnce(TransformPipeline) -> TransformPipeline + 'static,
Apply transformations only if the document matches a predicate
Sourcepub fn remove_empty_paragraphs(self) -> Self
pub fn remove_empty_paragraphs(self) -> Self
Remove empty paragraphs
Sourcepub fn remove_empty_text(self) -> Self
pub fn remove_empty_text(self) -> Self
Remove empty text elements
Sourcepub fn normalize_whitespace(self) -> Self
pub fn normalize_whitespace(self) -> Self
Normalize whitespace
Sourcepub fn filter_blocks<F>(self, predicate: F) -> Self
pub fn filter_blocks<F>(self, predicate: F) -> Self
Filter blocks by predicate
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TransformPipeline
impl !RefUnwindSafe for TransformPipeline
impl !Send for TransformPipeline
impl !Sync for TransformPipeline
impl Unpin for TransformPipeline
impl !UnwindSafe for TransformPipeline
Blanket Implementations§
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
Mutably borrows from an owned value. Read more