Fix table parsing

pull/1/head
trivernis 5 years ago
parent 269e26840f
commit d43410de70

2
Cargo.lock generated

@ -153,7 +153,7 @@ dependencies = [
[[package]] [[package]]
name = "snekdown" name = "snekdown"
version = "0.1.0" version = "0.1.1"
dependencies = [ dependencies = [
"crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"htmlescape 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "htmlescape 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",

@ -1,6 +1,6 @@
[package] [package]
name = "snekdown" name = "snekdown"
version = "0.1.0" version = "0.1.1"
authors = ["trivernis <trivernis@protonmail.com>"] authors = ["trivernis <trivernis@protonmail.com>"]
edition = "2018" edition = "2018"
license-file = "LICENSE" license-file = "LICENSE"

@ -58,6 +58,20 @@ Quote with metadata (e.g. Author)
Imports can be used to import a different document to be attached to the main document. Imports can be used to import a different document to be attached to the main document.
Imports are parsed via multithreading. Imports are parsed via multithreading.
### Tables
Tables MUST start with a pipe character `|`
```
Standalone header:
| header | header | header
Header with rows
| header | header | header
|--------|--------|-------
| row | row | row
```
``` ```
<[path] <[path]
``` ```

@ -601,16 +601,15 @@ impl Parser {
let header = self.parse_row()?; let header = self.parse_row()?;
self.seek_whitespace(); self.seek_whitespace();
let mut table = Table::new(header); let mut table = Table::new(header);
if self.check_special_group(&[MINUS, PIPE]) let seek_start = self.index;
&& self.next_char() != None
&& self.check_special_group(&[MINUS, PIPE])
{
while let Some(char) = self.next_char() { while let Some(char) = self.next_char() {
if char == '\n' { self.seek_inline_whitespace();
if char == '\n' || !self.check_special_group(&[MINUS, PIPE]) {
break; break;
} }
} }
} else { if !self.current_char.is_whitespace() || self.check_special_group(&[MINUS, PIPE]) {
self.revert_to(seek_start)?;
return Ok(table); return Ok(table);
} }

Loading…
Cancel
Save