use crate::Colour;
use crate::WhiteSpace;
pub(crate) mod text_renderer;
pub use text_renderer::{
PlainDecorator, RichAnnotation, RichDecorator, TaggedLine, TaggedLineElement, TextDecorator,
TrivialDecorator,
};
pub(crate) type Result<T> = std::result::Result<T, TooNarrow>;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct TooNarrow;
impl From<TooNarrow> for crate::Error {
fn from(_: TooNarrow) -> crate::Error {
crate::Error::TooNarrow
}
}
pub(crate) trait Renderer {
fn add_empty_line(&mut self) -> Result<()>;
fn new_sub_renderer(&self, width: usize) -> Result<Self>
where
Self: Sized;
fn start_block(&mut self) -> Result<()>;
fn start_table(&mut self) -> Result<()>;
fn end_block(&mut self);
fn new_line(&mut self) -> Result<()>;
fn new_line_hard(&mut self) -> Result<()>;
fn add_horizontal_border(&mut self) -> Result<()>;
fn add_horizontal_border_width(
&mut self,
#[allow(unused_variables)] width: usize,
) -> Result<()> {
self.add_horizontal_border()
}
fn push_preformat(&mut self);
fn pop_preformat(&mut self);
fn push_ws(&mut self, ws: WhiteSpace);
fn pop_ws(&mut self);
fn add_inline_text(&mut self, text: &str) -> Result<()>;
fn width(&self) -> usize;
fn append_subrender<'a, I>(&mut self, other: Self, prefixes: I) -> Result<()>
where
I: Iterator<Item = &'a str>;
fn append_columns_with_borders<I>(&mut self, cols: I, collapse: bool) -> Result<()>
where
I: IntoIterator<Item = (Self, usize)>,
Self: Sized;
fn append_vert_row<I>(&mut self, cols: I) -> Result<()>
where
I: IntoIterator<Item = Self>,
Self: Sized;
fn empty(&self) -> bool;
fn start_link(&mut self, target: &str) -> Result<()>;
fn end_link(&mut self) -> Result<()>;
fn start_emphasis(&mut self) -> Result<()>;
fn end_emphasis(&mut self) -> Result<()>;
fn start_strong(&mut self) -> Result<()>;
fn end_strong(&mut self) -> Result<()>;
fn start_strikeout(&mut self) -> Result<()>;
fn end_strikeout(&mut self) -> Result<()>;
fn start_code(&mut self) -> Result<()>;
fn end_code(&mut self) -> Result<()>;
fn add_image(&mut self, src: &str, title: &str) -> Result<()>;
fn header_prefix(&mut self, level: usize) -> String;
fn quote_prefix(&mut self) -> String;
fn unordered_item_prefix(&mut self) -> String;
fn ordered_item_prefix(&mut self, i: i64) -> String;
fn record_frag_start(&mut self, fragname: &str);
#[allow(unused)]
fn push_colour(&mut self, colour: Colour);
#[allow(unused)]
fn pop_colour(&mut self);
#[allow(unused)]
fn push_bgcolour(&mut self, colour: Colour);
#[allow(unused)]
fn pop_bgcolour(&mut self);
fn start_superscript(&mut self) -> Result<()>;
fn end_superscript(&mut self) -> Result<()>;
}