diff options
Diffstat (limited to 'src/parser')
| -rw-r--r-- | src/parser/conversion/inline.rs | 8 | ||||
| -rw-r--r-- | src/parser/tests.rs | 14 | 
2 files changed, 19 insertions, 3 deletions
| diff --git a/src/parser/conversion/inline.rs b/src/parser/conversion/inline.rs index ed118c3..297680a 100644 --- a/src/parser/conversion/inline.rs +++ b/src/parser/conversion/inline.rs @@ -5,7 +5,8 @@ use crate::document_tree::{  	elements as e,  	element_categories as c,  	extra_attributes as a, -	attribute_types as at +	attribute_types as at, +	element_categories::HasChildren,  };  use crate::parser::{ @@ -19,9 +20,12 @@ use super::whitespace_normalize_name;  pub fn convert_inline(pair: Pair<Rule>) -> Result<c::TextOrInlineElement, Error> {  	Ok(match pair.as_rule() { -		Rule::str              => pair.as_str().into(), +		Rule::str | Rule::str_nested => pair.as_str().into(),  		Rule::reference        => convert_reference(pair)?,  		Rule::substitution_ref => convert_substitution_ref(pair)?.into(), +		Rule::emph             => e::Emphasis::with_children(convert_inlines(pair)?).into(), +		Rule::strong           => e::Strong::with_children(convert_inlines(pair)?).into(), +		Rule::literal          => e::Literal::with_children(convert_inlines(pair)?).into(),  		rule => unimplemented!("unknown rule {:?}", rule),  	})  } diff --git a/src/parser/tests.rs b/src/parser/tests.rs index bf9fe22..e161108 100644 --- a/src/parser/tests.rs +++ b/src/parser/tests.rs @@ -17,6 +17,18 @@ fn plain() {  }  #[test] +fn emph_only() { +	parses_to! { +		parser: RstParser, +		input: "*emphasis*", +		rule: Rule::emph_outer, +		tokens: [ +			emph(1, 9, [str_nested(1, 9)]) +		] +	}; +} + +#[test]  fn emph() {  	parses_to! {  		parser: RstParser, @@ -25,7 +37,7 @@ fn emph() {  		tokens: [  			paragraph(0, 18, [  				str(0, 5), -				emph(6, 17), +				emph(6, 17, [str_nested(6, 17)]),  			])  		]  	}; | 
