WIP markup to html parser func.
This commit is contained in:
parent
c07d240532
commit
d7af108833
@ -15,6 +15,7 @@ log = "0.3.8"
|
||||
loggerv = "0.6.0"
|
||||
open = "1.2.1"
|
||||
rayon = "0.9.0"
|
||||
regex = "0.2.3"
|
||||
|
||||
[dependencies.diesel]
|
||||
features = ["sqlite"]
|
||||
|
||||
@ -12,6 +12,7 @@ extern crate hammond_downloader;
|
||||
extern crate log;
|
||||
extern crate loggerv;
|
||||
extern crate open;
|
||||
extern crate regex;
|
||||
// extern crate rayon;
|
||||
|
||||
// use rayon::prelude::*;
|
||||
|
||||
@ -9,8 +9,10 @@ use hammond_downloader::downloader;
|
||||
use std::{thread, time};
|
||||
use std::cell::RefCell;
|
||||
use std::sync::mpsc::{channel, Receiver};
|
||||
use std::borrow::Cow;
|
||||
|
||||
use content;
|
||||
use regex::Regex;
|
||||
|
||||
type Foo = RefCell<Option<(gtk::Stack, Receiver<bool>)>>;
|
||||
|
||||
@ -69,6 +71,18 @@ pub fn get_pixbuf_from_path(pd: &Podcast) -> Option<Pixbuf> {
|
||||
Pixbuf::new_from_file_at_scale(&img_path, 256, 256, true).ok()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
// WIP: parse html to markup
|
||||
pub fn html_to_markup(s: &mut str) -> Cow<str> {
|
||||
s.trim();
|
||||
s.replace('&', "&");
|
||||
s.replace('<', "<");
|
||||
s.replace('>', ">");
|
||||
|
||||
let re = Regex::new("(?P<url>https?://[^\\s&,)(\"]+(&\\w=[\\w._-]?)*(#[\\w._-]+)?)").unwrap();
|
||||
re.replace_all(s, "<a href=\"$url\">$url</a>")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use hammond_data::Source;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user