aboutsummaryrefslogtreecommitdiffstats
path: root/src/parser/conversion/block.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser/conversion/block.rs')
-rw-r--r--src/parser/conversion/block.rs13
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,