mirror of
https://github.com/YGGverse/ggemtext.git
synced 2026-03-31 09:05:32 +00:00
update readme
This commit is contained in:
parent
96f7d648b6
commit
92e1557c9c
1 changed files with 6 additions and 14 deletions
20
README.md
20
README.md
|
|
@ -20,20 +20,6 @@ cargo add ggemtext
|
||||||
|
|
||||||
Line parser, useful for [TextTag](https://docs.gtk.org/gtk4/class.TextTag.html) operations in [TextBuffer](https://docs.gtk.org/gtk4/class.TextBuffer.html) context.
|
Line parser, useful for [TextTag](https://docs.gtk.org/gtk4/class.TextTag.html) operations in [TextBuffer](https://docs.gtk.org/gtk4/class.TextBuffer.html) context.
|
||||||
|
|
||||||
**Connect dependencies**
|
|
||||||
|
|
||||||
``` rust
|
|
||||||
use ggemtext::line::{
|
|
||||||
code::{Inline, Multiline},
|
|
||||||
header::{Header, Level},
|
|
||||||
link::Link,
|
|
||||||
list::List,
|
|
||||||
quote::Quote,
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Prepare document**
|
|
||||||
|
|
||||||
Iterate Gemtext lines to continue with [Line](#Line) API:
|
Iterate Gemtext lines to continue with [Line](#Line) API:
|
||||||
|
|
||||||
``` rust
|
``` rust
|
||||||
|
|
@ -47,6 +33,7 @@ for line in gemtext.lines() {
|
||||||
##### Inline
|
##### Inline
|
||||||
|
|
||||||
``` rust
|
``` rust
|
||||||
|
use ggemtext::line::code::Inline;
|
||||||
match Inline::from("```inline```") {
|
match Inline::from("```inline```") {
|
||||||
Some(inline) => assert_eq!(inline.value, "inline"),
|
Some(inline) => assert_eq!(inline.value, "inline"),
|
||||||
None => assert!(false),
|
None => assert!(false),
|
||||||
|
|
@ -56,6 +43,7 @@ match Inline::from("```inline```") {
|
||||||
##### Multiline
|
##### Multiline
|
||||||
|
|
||||||
``` rust
|
``` rust
|
||||||
|
use ggemtext::line::code::Multiline;
|
||||||
match Multiline::begin_from("```alt") {
|
match Multiline::begin_from("```alt") {
|
||||||
Some(mut multiline) => {
|
Some(mut multiline) => {
|
||||||
assert!(Multiline::continue_from(&mut multiline, "line 1").is_ok());
|
assert!(Multiline::continue_from(&mut multiline, "line 1").is_ok());
|
||||||
|
|
@ -75,6 +63,7 @@ match Multiline::begin_from("```alt") {
|
||||||
**Struct**
|
**Struct**
|
||||||
|
|
||||||
``` rust
|
``` rust
|
||||||
|
use ggemtext::line::{Header, header::Level};
|
||||||
match Header::parse("# H1") {
|
match Header::parse("# H1") {
|
||||||
Some(h1) => {
|
Some(h1) => {
|
||||||
assert_eq!(h1.level as u8, Level::H1 as u8);
|
assert_eq!(h1.level as u8, Level::H1 as u8);
|
||||||
|
|
@ -96,6 +85,7 @@ assert_eq!("H1".to_source(&Level::H1), "# H1");
|
||||||
#### Link
|
#### Link
|
||||||
|
|
||||||
``` rust
|
``` rust
|
||||||
|
use ggemtext::line::Link;
|
||||||
match Link::from(
|
match Link::from(
|
||||||
"=> gemini://geminiprotocol.net 1965-01-19 Gemini",
|
"=> gemini://geminiprotocol.net 1965-01-19 Gemini",
|
||||||
None, // absolute path given, base not wanted
|
None, // absolute path given, base not wanted
|
||||||
|
|
@ -127,6 +117,7 @@ match Link::from(
|
||||||
**Struct**
|
**Struct**
|
||||||
|
|
||||||
``` rust
|
``` rust
|
||||||
|
use ggemtext::line::List;
|
||||||
match List::parse("* Item") {
|
match List::parse("* Item") {
|
||||||
Some(list) => assert_eq!(list.value, "Item"),
|
Some(list) => assert_eq!(list.value, "Item"),
|
||||||
None => assert!(false),
|
None => assert!(false),
|
||||||
|
|
@ -146,6 +137,7 @@ assert_eq!("Item".to_source(), "* Item")
|
||||||
**Struct**
|
**Struct**
|
||||||
|
|
||||||
``` rust
|
``` rust
|
||||||
|
use ggemtext::line::Quote;
|
||||||
match Quote::parse("> Quote") {
|
match Quote::parse("> Quote") {
|
||||||
Some(quote) => assert_eq!(quote.value, "Quote"),
|
Some(quote) => assert_eq!(quote.value, "Quote"),
|
||||||
None => assert!(false),
|
None => assert!(false),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue