pub struct DocumentView { /* private fields */ }Expand description
A parsed document, ready to print. Build one from source with
org, asciidoc or man,
or from a Document built by hand with new.
use rich::Console;
use rich_ext::document::DocumentView;
let console = Console::builder().width(40).color_system(None).build();
let view = DocumentView::org("* TODO Write the report :work:\nSome /italic/ text.");
let out = console.render_to_string(&view);
assert!(out.contains("TODO Write the report"));
assert!(out.contains("Some italic text."));Implementations§
Source§impl DocumentView
impl DocumentView
Sourcepub fn new(document: Document) -> Self
pub fn new(document: Document) -> Self
Draw document with the default RenderOptions.
Sourcepub fn from_parsed(parsed: Parsed) -> Self
pub fn from_parsed(parsed: Parsed) -> Self
Draw what a parser returned, keeping its diagnostics.
Sourcepub fn options(self, options: RenderOptions) -> Self
pub fn options(self, options: RenderOptions) -> Self
Replace every render option.
Sourcepub fn hyperlinks(self, hyperlinks: bool) -> Self
pub fn hyperlinks(self, hyperlinks: bool) -> Self
Whether links carry OSC 8 hyperlinks (see RenderOptions::hyperlinks).
Sourcepub fn code_theme(self, theme: impl Into<String>) -> Self
pub fn code_theme(self, theme: impl Into<String>) -> Self
The Syntax theme for code blocks.
Sourcepub fn default_language(self, language: impl Into<String>) -> Self
pub fn default_language(self, language: impl Into<String>) -> Self
The language of code blocks that name none.
Sourcepub fn fence_renderer(self, renderer: Arc<dyn FenceRenderer>) -> Self
pub fn fence_renderer(self, renderer: Arc<dyn FenceRenderer>) -> Self
Ask renderer first for code blocks with a language.
Sourcepub fn diagnostics(&self) -> &[Diagnostic]
pub fn diagnostics(&self) -> &[Diagnostic]
What the parser could not show as written.
Sourcepub fn render_options(&self) -> &RenderOptions
pub fn render_options(&self) -> &RenderOptions
The render options.
Trait Implementations§
Source§impl Clone for DocumentView
impl Clone for DocumentView
Source§impl Debug for DocumentView
impl Debug for DocumentView
Source§impl Renderable for DocumentView
impl Renderable for DocumentView
fn rich_render( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>
Source§fn measure(&self, _console: &Console, options: &ConsoleOptions) -> Measurement
fn measure(&self, _console: &Console, options: &ConsoleOptions) -> Measurement
The
(minimum, maximum) cell width this renderable wants. Port of
__rich_measure__. The default is what upstream’s Measurement.get
returns for a renderable without one: anything from nothing to the
whole width, (0, max_width).Source§fn fit_to_measurement(&self) -> bool
fn fit_to_measurement(&self) -> bool
Whether a top-level
Console::print shrinks this renderable to its
measured width. Upstream renders every top-level renderable at the full
console width, so the default is false; an extension may opt in.Source§fn vertical(&self) -> Option<VerticalAlign>
fn vertical(&self) -> Option<VerticalAlign>
The vertical alignment a
Table cell holding this renderable uses in
place of its column’s. Upstream reads getattr(renderable, "vertical", None); Align sets it.Source§fn print_end_line(&self, _options: &ConsoleOptions) -> bool
fn print_end_line(&self, _options: &ConsoleOptions) -> bool
Whether a top-level print ends this renderable’s last line. This
port’s renderables separate lines, where upstream’s end each line
with
"\n", so a print adds the final line break. A renderable
whose upstream output stops without one (Screen, LiveRender, a
Rule whose end has no newline) returns false, and the next
output continues its last line. options are the print’s options.Auto Trait Implementations§
impl !RefUnwindSafe for DocumentView
impl !UnwindSafe for DocumentView
impl Freeze for DocumentView
impl Send for DocumentView
impl Sync for DocumentView
impl Unpin for DocumentView
impl UnsafeUnpin for DocumentView
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