mirror of
https://github.com/YGGverse/ggemtext.git
synced 2026-03-31 17:15:33 +00:00
use namespace
This commit is contained in:
parent
541683808c
commit
6f3d4e0f58
1 changed files with 9 additions and 8 deletions
|
|
@ -6,9 +6,12 @@ use ggemtext::line::{
|
||||||
quote::Quote,
|
quote::Quote,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use gtk::glib::{TimeZone, Uri, UriFlags};
|
||||||
|
use std::fs::read_to_string;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn gemtext() {
|
fn gemtext() {
|
||||||
match std::fs::read_to_string("tests/integration_test.gmi") {
|
match read_to_string("tests/integration_test.gmi") {
|
||||||
Ok(gemtext) => {
|
Ok(gemtext) => {
|
||||||
// Init tags collection
|
// Init tags collection
|
||||||
let mut code_inline: Vec<Inline> = Vec::new();
|
let mut code_inline: Vec<Inline> = Vec::new();
|
||||||
|
|
@ -22,14 +25,14 @@ fn gemtext() {
|
||||||
let mut code_multiline_buffer: Option<Multiline> = None;
|
let mut code_multiline_buffer: Option<Multiline> = None;
|
||||||
|
|
||||||
// Define base URI as integration_test.gmi contain one relative link
|
// Define base URI as integration_test.gmi contain one relative link
|
||||||
let base = match gtk::glib::Uri::parse(
|
let base = match Uri::parse("gemini://geminiprotocol.net", UriFlags::NONE) {
|
||||||
"gemini://geminiprotocol.net",
|
|
||||||
gtk::glib::UriFlags::NONE,
|
|
||||||
) {
|
|
||||||
Ok(uri) => Some(uri),
|
Ok(uri) => Some(uri),
|
||||||
Err(_) => None,
|
Err(_) => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Define timezone as integration_test.gmi contain one links with date
|
||||||
|
let timezone = Some(TimeZone::local());
|
||||||
|
|
||||||
// Parse document by line
|
// Parse document by line
|
||||||
for line in gemtext.lines() {
|
for line in gemtext.lines() {
|
||||||
// Inline code
|
// Inline code
|
||||||
|
|
@ -59,9 +62,7 @@ fn gemtext() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Link
|
// Link
|
||||||
if let Some(result) =
|
if let Some(result) = Link::from(line, base.as_ref(), timezone.as_ref()) {
|
||||||
Link::from(line, base.as_ref(), Some(>k::glib::TimeZone::local()))
|
|
||||||
{
|
|
||||||
link.push(result);
|
link.push(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue