pub struct MarkdownRenderer { /* private fields */ }Expand description
A struct to handle rendering JSON into Markdown format.
The MarkdownRenderer provides customizable options for indentation and depth handling.
Implementations§
Source§impl MarkdownRenderer
impl MarkdownRenderer
Sourcepub fn new(indent_spaces: usize, depth_increment: usize) -> Self
pub fn new(indent_spaces: usize, depth_increment: usize) -> Self
Creates a new MarkdownRenderer.
§Arguments
indent_spaces- Number of spaces to use for indentation. Always try to use1at first.depth_increment- Increment to apply for nested structures. Always try to use2at first
You can experiment with different values, it still not perfect.
§Examples
let renderer = MarkdownRenderer::new(1, 2);Sourcepub fn render(&self, json: &Value) -> String
pub fn render(&self, json: &Value) -> String
Renders a JSON value into a Markdown string.
§Arguments
json- The JSON value to render.
§Returns
A String containing the rendered Markdown.
§Examples
let renderer = MarkdownRenderer::new(1, 2);
let json = serde_json::json!({"title": "My Document"});
let markdown = renderer.render(&json);
assert_eq!(markdown, "");Auto Trait Implementations§
impl Freeze for MarkdownRenderer
impl RefUnwindSafe for MarkdownRenderer
impl Send for MarkdownRenderer
impl Sync for MarkdownRenderer
impl Unpin for MarkdownRenderer
impl UnwindSafe for MarkdownRenderer
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