text2html 0.0.1

A library render text to html in Rust
Documentation
  • Coverage
  • 0%
    0 out of 16 items documented0 out of 11 items with examples
  • Size
  • Source code size: 22.26 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.68 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • zTgx/text2html
    3 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • zTgx

text2html

an exprimental project.

WIP
A library render text to html in Rust.

Usage

Add this to your Cargo.toml:

[dependencies]

text2html = "0.0.1"


Example:

pub struct Content <'b> {
    pub c: &'b String,
}
impl <'b> Content <'b> {
    pub fn new(s: &'b String) -> Self {
        Content {
            c: s,
        }
    }
}
impl <'b> Text for Content <'b> {
    fn data_source(&mut self) -> String {
        self.c.to_owned()
    }
}

pub struct TextBuilder <'a> {
    pub sc: &'a String,
}
impl <'a> TextBuilder <'a> {
    pub fn new(s: &'a String) -> Self {
        TextBuilder {
            sc: s,
        }
    }
}
impl <'a> TextBuilder <'a> {
    pub fn build(&mut self) -> Box<dyn Text + 'a> {
        Box::new( Content::new(&self.sc) )
    }
}

fn main() {
    let text = "Hello world.".to_string();
    let mut builder = TextBuilder::new( &text ).build();
    HtmlRender::new().render(&mut builder);
}