mirror of
https://github.com/TxtDot/dalet-rs.git
synced 2024-12-25 01:53:46 +03:00
fix: text tag syntax, table escaping, body parsing
This commit is contained in:
parent
3438b2a375
commit
4e3cfc7fec
5 changed files with 31 additions and 18 deletions
|
@ -34,9 +34,9 @@ meta "description": This document describes Daleth syntax and some tags
|
||||||
h1: TxtDot revolution
|
h1: TxtDot revolution
|
||||||
p: TxtDot is a cool project
|
p: TxtDot is a cool project
|
||||||
|
|
||||||
# If no tag is specified, then the 'el' tag is placed
|
# If no tag is specified, but "- text" present, then the 'el' tag is placed
|
||||||
|
|
||||||
This is element
|
- This is element
|
||||||
br
|
br
|
||||||
|
|
||||||
# if no tag is specified but a '{- text}' is present, then the 'p' tag is placed
|
# if no tag is specified but a '{- text}' is present, then the 'p' tag is placed
|
||||||
|
@ -55,7 +55,7 @@ row "center" [
|
||||||
btn "https://example.com/donate" [
|
btn "https://example.com/donate" [
|
||||||
# tag without body
|
# tag without body
|
||||||
img "https://example.com/donate.png"
|
img "https://example.com/donate.png"
|
||||||
Donate
|
- Donate
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -63,19 +63,20 @@ row "center" [
|
||||||
row [
|
row [
|
||||||
# if no tag is specified but a '[[]]' is present, then the 'el' tag
|
# if no tag is specified but a '[[]]' is present, then the 'el' tag
|
||||||
# with multiple tags body placed
|
# with multiple tags body placed
|
||||||
|
|
||||||
[[
|
[[
|
||||||
h2: Features
|
h2: Features
|
||||||
|
|
||||||
ul [
|
ul [
|
||||||
Server-side page simplification
|
- Server-side page simplification
|
||||||
Media proxy
|
- Media proxy
|
||||||
Image compression with Sharp
|
- Image compression with Sharp
|
||||||
Rendering client-side apps `Vanilla, React, Vue, etc` with webder
|
- Rendering client-side apps `Vanilla, React, Vue, etc` with webder
|
||||||
Search with SearXNG
|
- Search with SearXNG
|
||||||
Handy API endpoints
|
- Handy API endpoints
|
||||||
No client JavaScript
|
- No client JavaScript
|
||||||
Some kind of Material Design 3
|
- Some kind of Material Design 3
|
||||||
Customization with plugins, see @txtdot/sdk and @txtdot/plugins
|
- Customization with plugins, see @txtdot/sdk and @txtdot/plugins
|
||||||
]
|
]
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,22 @@ pub fn table_to_tag(rows: &Vec<TableCol>) -> Tag {
|
||||||
.map(|row| match row {
|
.map(|row| match row {
|
||||||
TableCol::Primary(row) => Tag::Tprow(
|
TableCol::Primary(row) => Tag::Tprow(
|
||||||
row.into_iter()
|
row.into_iter()
|
||||||
.map(|t| Tag::El(NNBody::Text(format!("{t}"))))
|
.map(|t| {
|
||||||
|
Tag::El(NNBody::Text(format!(
|
||||||
|
"{}",
|
||||||
|
t.replace("\\]", "]").replace("\\|", "|")
|
||||||
|
)))
|
||||||
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
),
|
),
|
||||||
TableCol::Secondary(row) => Tag::Trow(
|
TableCol::Secondary(row) => Tag::Trow(
|
||||||
row.into_iter()
|
row.into_iter()
|
||||||
.map(|t| Tag::El(NNBody::Text(format!("{t}"))))
|
.map(|t| {
|
||||||
|
Tag::El(NNBody::Text(format!(
|
||||||
|
"{}",
|
||||||
|
t.replace("\\]", "]").replace("\\|", "|")
|
||||||
|
)))
|
||||||
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
|
@ -104,7 +104,9 @@ pub fn format<'src>(spanned_tokens: &Vec<Spanned<Token<'src>>>) -> String {
|
||||||
Token::MLRText(t) => format!(" {{#{t}}}\n"),
|
Token::MLRText(t) => format!(" {{#{t}}}\n"),
|
||||||
Token::Comment(c) => format!("{}\n", prepend_indent(&format!("#{c}"), current_indent)),
|
Token::Comment(c) => format!("{}\n", prepend_indent(&format!("#{c}"), current_indent)),
|
||||||
|
|
||||||
Token::TextTag(t) => format!("{}\n", prepend_indent(t, current_indent)),
|
Token::TextTag(t) => {
|
||||||
|
format!("{}\n", prepend_indent(&format!("- {}", t), current_indent))
|
||||||
|
}
|
||||||
|
|
||||||
Token::El => prepend_indent("el", current_indent),
|
Token::El => prepend_indent("el", current_indent),
|
||||||
Token::H => prepend_indent("h", current_indent),
|
Token::H => prepend_indent("h", current_indent),
|
||||||
|
|
|
@ -122,8 +122,8 @@ fn textual<'src>() -> impl Parser<'src, &'src str, Token<'src>, extra::Err<Rich<
|
||||||
.map(Token::TextBody)
|
.map(Token::TextBody)
|
||||||
.labelled("One line text body");
|
.labelled("One line text body");
|
||||||
|
|
||||||
let text_tag = text
|
let text_tag = just('-')
|
||||||
.then_ignore(just('\n'))
|
.ignore_then(text)
|
||||||
.map(Token::TextTag)
|
.map(Token::TextTag)
|
||||||
.labelled("Text tag");
|
.labelled("Text tag");
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ pub fn tag<'tokens, 'src: 'tokens>(
|
||||||
.map(Body::Text)
|
.map(Body::Text)
|
||||||
.or(tags_body.clone().map(Body::Tags))
|
.or(tags_body.clone().map(Body::Tags))
|
||||||
.or_not()
|
.or_not()
|
||||||
.to(Body::Null)
|
.map(|v| v.unwrap_or(Body::Null))
|
||||||
.labelled("Body");
|
.labelled("Body");
|
||||||
|
|
||||||
let num_arg = select! {
|
let num_arg = select! {
|
||||||
|
|
Loading…
Add table
Reference in a new issue