mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
add text/plain content type support
This commit is contained in:
parent
63d2821c07
commit
f2da250376
6 changed files with 75 additions and 64 deletions
|
|
@ -113,21 +113,7 @@ impl Content {
|
|||
status
|
||||
}
|
||||
|
||||
/// Set new `content::Text` component for `Self` with new `text::Gemini` preset
|
||||
///
|
||||
/// Useful as reader for [Gemtext](https://geminiprotocol.net/docs/gemtext.gmi)
|
||||
///
|
||||
/// * action removes previous children component from `Self`
|
||||
///
|
||||
/// **Arguments**
|
||||
///
|
||||
/// * `base` - [Uri](https://docs.gtk.org/glib/struct.Uri.html) to resolve relative links in Gemtext
|
||||
/// * `data` - Gemtext source to be parsed
|
||||
///
|
||||
/// **Return**
|
||||
///
|
||||
/// `Text` component with it public API
|
||||
/// * could be useful to extract document title parsed from Gemtext
|
||||
/// `text/gemini`
|
||||
pub fn to_text_gemini(&self, base: &Uri, data: &str) -> Text {
|
||||
self.clean();
|
||||
let text = Text::gemini((&self.window_action, &self.item_action), base, data);
|
||||
|
|
@ -135,6 +121,15 @@ impl Content {
|
|||
text
|
||||
}
|
||||
|
||||
/// `text/plain`
|
||||
pub fn to_text_plain(&self, data: &str) -> Text {
|
||||
self.clean();
|
||||
let text = Text::plain(data);
|
||||
self.g_box.append(&text.scrolled_window);
|
||||
text
|
||||
}
|
||||
|
||||
/// * system `source:`
|
||||
pub fn to_text_source(&self, data: &str) -> Text {
|
||||
self.clean();
|
||||
let text = Text::source(data);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue