diff options
| author | Philipp A | 2023-12-28 15:37:38 +0100 | 
|---|---|---|
| committer | GitHub | 2023-12-28 14:37:38 +0000 | 
| commit | 774dd4798aedc40b38c6480e9c47f34c482f12d0 (patch) | |
| tree | 48411fb82c50de0ba07282bc5d6f333305f48f4e | |
| parent | 2a76f2dde6533c09f8e93b44d1f214a105d9c5c2 (diff) | |
| download | rust-rst-774dd4798aedc40b38c6480e9c47f34c482f12d0.tar.bz2 | |
Trailing newlines (#31)
| -rw-r--r-- | parser/src/rst.pest | 2 | ||||
| -rw-r--r-- | rst/src/main.rs | 6 | 
2 files changed, 6 insertions, 2 deletions
| diff --git a/parser/src/rst.pest b/parser/src/rst.pest index dbf201d..f942547 100644 --- a/parser/src/rst.pest +++ b/parser/src/rst.pest @@ -5,7 +5,7 @@  // Section headers define the hierarchy by their delimiters,  // and pest only has one stack that we need for indentation. -document = _{ SOI ~ blocks ~ EOI } +document = _{ SOI ~ blank_line* ~ blocks ~ EOI }  blocks   = _{ block ~ (blank_line* ~ block)* ~ blank_line? }  block    = _{ PEEK[..] ~ hanging_block } diff --git a/rst/src/main.rs b/rst/src/main.rs index 0339ce1..8b616f9 100644 --- a/rst/src/main.rs +++ b/rst/src/main.rs @@ -32,7 +32,11 @@ fn main() -> CliResult {      args.verbosity.setup_env_logger("rst")?;      // TODO: somehow make it work without replacing tabs -    let content = read_file(args.file)?.replace('\t', " ".repeat(8).as_ref()); +    let mut content = read_file(args.file)?.replace('\t', " ".repeat(8).as_ref()); +    // Allows for less complex grammar +    if !content.ends_with('\n') { +        content.push('\n'); +    }      let document = parse(&content)?;      let stdout = std::io::stdout();      match args.format { | 
