Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ztgx/text2html
A library for which render text to html in Rust
https://github.com/ztgx/text2html
Last synced: 2 days ago
JSON representation
A library for which render text to html in Rust
- Host: GitHub
- URL: https://github.com/ztgx/text2html
- Owner: zTgx
- License: apache-2.0
- Created: 2019-08-09T09:43:21.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-28T04:00:36.000Z (over 5 years ago)
- Last Synced: 2024-12-19T12:11:22.986Z (27 days ago)
- Language: Rust
- Size: 7.81 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# [text2html](https://github.com/zTgx/text2html) [![Build Status](https://travis-ci.org/zTgx/text2html.svg?branch=master)](https://travis-ci.org/zTgx/text2html) [![crate](https://img.shields.io/crates/v/text2html.svg)](https://crates.io/crates/text2html)
#### an exprimental project.
WIP
A library render text to html in Rust.## Usage
Add this to your `Cargo.toml`:
```toml
[dependencies]
text2html = "0.0.1"
```---
Example:
```rust
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 {
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);
}
```