diff options
| author | Philipp A | 2018-12-02 17:22:51 +0100 |
|---|---|---|
| committer | Philipp A | 2018-12-02 17:22:51 +0100 |
| commit | d067cee68744691f3aebd939befc9837247e639c (patch) | |
| tree | 6f8ff1ba9617a6f55f7c667457c0f009f01300fe /src/parser/conversion/block.rs | |
| parent | c7bf1a581871a5bb13195d116d9dc7b83eb83c3a (diff) | |
| download | rust-rst-d067cee68744691f3aebd939befc9837247e639c.tar.bz2 | |
First bit of inlines parsing
Diffstat (limited to 'src/parser/conversion/block.rs')
| -rw-r--r-- | src/parser/conversion/block.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/parser/conversion/block.rs b/src/parser/conversion/block.rs index 0b638e7..5a92ed6 100644 --- a/src/parser/conversion/block.rs +++ b/src/parser/conversion/block.rs @@ -13,20 +13,20 @@ use crate::parser::{ pest_rst::Rule, pair_ext_parse::PairExt, }; -use super::ConversionError; +use super::inline::convert_inline; pub fn convert_ssubel(pair: Pair<Rule>) -> Result<Option<c::StructuralSubElement>, Error> { // TODO: This is just a proof of concep. Keep closely to DTD in final version! Ok(Some(match pair.as_rule() { Rule::title => convert_title(pair).into(), - Rule::paragraph => e::Paragraph::with_children(vec![pair.as_str().into()]).into(), + Rule::paragraph => convert_paragraph(pair)?.into(), Rule::target => convert_target(pair)?.into(), Rule::substitution_def => convert_substitution_def(pair)?.into(), Rule::admonition_gen => convert_admonition_gen(pair)?.into(), Rule::image => convert_image::<e::Image>(pair)?.into(), Rule::EOI => return Ok(None), - rule => return Err(ConversionError::UnknownRuleError { rule }.into()), + rule => panic!("unknown rule {:?}", rule), })) } @@ -47,6 +47,13 @@ fn convert_title(pair: Pair<Rule>) -> e::Title { ]) } + +fn convert_paragraph(pair: Pair<Rule>) -> Result<e::Paragraph, Error> { + let children = pair.into_inner().map(convert_inline).collect::<Result<_,_>>()?; + Ok(e::Paragraph::with_children(children)) +} + + fn convert_target(pair: Pair<Rule>) -> Result<e::Target, Error> { let mut attrs = a::Target { anonymous: false, |
