init markup builder

This commit is contained in:
yggverse 2024-09-26 20:36:04 +03:00
parent 2485595b58
commit d9fd0d12c3

View File

@ -1,3 +1,7 @@
mod parser;
use parser::header::Header;
use gtk::{ use gtk::{
prelude::{StyleContextExt, WidgetExt}, prelude::{StyleContextExt, WidgetExt},
Align, CssProvider, Label, STYLE_PROVIDER_PRIORITY_APPLICATION, Align, CssProvider, Label, STYLE_PROVIDER_PRIORITY_APPLICATION,
@ -11,6 +15,16 @@ pub struct Reader {
impl Reader { impl Reader {
// Construct // Construct
pub fn new(gemtext: &str) -> Self { pub fn new(gemtext: &str) -> Self {
// Init markup
let mut markup = String::new();
for line in gemtext.lines() {
if let Some(header) = Header::from(line) {
markup.push_str(header.markup());
continue;
}
}
// Init CSS // Init CSS
let css = CssProvider::new(); let css = CssProvider::new();
@ -22,13 +36,14 @@ impl Reader {
let widget = Label::builder() let widget = Label::builder()
.halign(Align::Start) .halign(Align::Start)
.valign(Align::Start) .valign(Align::Start)
.hexpand(true) // @TODO
.vexpand(true) .vexpand(true)
.margin_start(8) .margin_start(8)
.margin_end(8) .margin_end(8)
.wrap(true) .wrap(true)
.selectable(true) .selectable(true)
.use_markup(true) .use_markup(true)
.label(gemtext) // @TODO .label(markup)
.build(); .build();
widget widget