M README.textile => README.textile +1 -1
@@ 5,7 5,7 @@ h1. Flatiron
A parser and HTML renderer for the "Textile markup language":https://web.archive.org/web/20021226034931/http://textism.com/article/648/ , written in rust.
bq. "she's an outlaw loose and runnin' came the whisper from each lip,
-and she's here to do -#REDACTED#- with the flatiron on her hip..." 🎵
+and she's here to do -REDACTED- with the flatiron on her hip..." 🎵
h2. Principles
M src/parse.rs => src/parse.rs +4 -1
@@ 171,7 171,10 @@ impl PhraseKind {
}
pub fn textile(input: &str) -> IResult<&str, Textile> {
- let (rest, blocks) = many0(terminated(block, many0(line_ending)))(input)?;
+ let (rest, blocks) = preceded(
+ many0(line_ending),
+ many0(terminated(block, many0(line_ending))),
+ )(input)?;
Ok((rest, Textile(blocks)))
}
M tests/textile.rs => tests/textile.rs +42 -13
@@ 2,24 2,53 @@ use flatiron::parse::*;
#[test]
fn textile_basic() {
- let input = "h2{color:green}. This is a title";
+ let input = "h2{color:green}. This is a title
+
+This is a paragraph with some _emphasized text_.";
let result = textile(input);
assert_eq!(
result,
Ok((
"",
- Textile(vec![BlockTag::Basic {
- kind: BlockKind::Header(2),
- indent: None,
- align: None,
- attributes: Some(Attributes {
- class: None,
- id: None,
- style: Some(String::from("color:green")),
- language: None,
- }),
- content: InlineTag::Plaintext(String::from("This is a title"))
- }])
+ Textile(vec![
+ BlockTag::Basic {
+ kind: BlockKind::Header(2),
+ indent: None,
+ align: None,
+ attributes: Some(Attributes {
+ class: None,
+ id: None,
+ style: Some(String::from("color:green")),
+ language: None,
+ }),
+ content: InlineTag::Plaintext(String::from(
+ "This is a title"
+ ))
+ },
+ BlockTag::Basic {
+ kind: BlockKind::Paragraph,
+ indent: None,
+ align: None,
+ attributes: None,
+ content: InlineTag::Phrase {
+ kind: None,
+ attributes: None,
+ content: vec![
+ InlineTag::Plaintext(String::from(
+ "This is a paragraph with some "
+ )),
+ InlineTag::Phrase {
+ kind: Some(PhraseKind::Emphasis),
+ attributes: None,
+ content: vec![InlineTag::Plaintext(
+ String::from("emphasized text")
+ )]
+ },
+ InlineTag::Plaintext(String::from(".")),
+ ]
+ }
+ }
+ ])
))
);
}