diff options
| author | Philipp A | 2018-12-02 20:43:34 +0100 |
|---|---|---|
| committer | Philipp A | 2018-12-02 20:43:34 +0100 |
| commit | a22f1caf79d947ce860f9a4751c583bc90393069 (patch) | |
| tree | 27a5ccf76deb4c7fe65ea688a13eb319320ffc1e /src/parser | |
| parent | b46de05f56960074edff80d24af48f59f163e293 (diff) | |
| download | rust-rst-a22f1caf79d947ce860f9a4751c583bc90393069.tar.bz2 | |
wonkily add names and so on
Diffstat (limited to 'src/parser')
| -rw-r--r-- | src/parser/conversion/block.rs | 13 | ||||
| -rw-r--r-- | src/parser/conversion/inline.rs | 6 |
2 files changed, 12 insertions, 7 deletions
diff --git a/src/parser/conversion/block.rs b/src/parser/conversion/block.rs index d99f38f..bca8559 100644 --- a/src/parser/conversion/block.rs +++ b/src/parser/conversion/block.rs @@ -5,7 +5,7 @@ use crate::document_tree::{ Element,HasChildren,ExtraAttributes, elements as e, element_categories as c, - attribute_types::ID, + attribute_types::{ID,NameToken}, extra_attributes as a, }; @@ -61,8 +61,11 @@ fn convert_target(pair: Pair<Rule>) -> Result<e::Target, Error> { }; for p in pair.into_inner() { match p.as_rule() { - // TODO: or is it refnames? - Rule::target_name_uq | Rule::target_name_qu => attrs.refid = Some(ID(p.as_str().to_owned())), + Rule::target_name_uq | Rule::target_name_qu => { + //TODO: abstract + attrs.refid = Some( ID(p.as_str().to_owned().replace(' ', "-"))); + attrs.refname.push(NameToken(p.as_str().to_owned())); + }, Rule::link_target => attrs.refuri = Some(p.parse()?), rule => panic!("Unexpected rule in target: {:?}", rule), } @@ -79,7 +82,7 @@ fn convert_substitution_def(pair: Pair<Rule>) -> Result<e::SubstitutionDefinitio rule => panic!("Unknown substitution rule {:?}", rule), }; let mut subst_def = e::SubstitutionDefinition::with_children(vec![inner.into()]); - subst_def.names_mut().push(name.to_owned()); + subst_def.names_mut().push(NameToken(name.to_owned())); Ok(subst_def) } @@ -96,7 +99,7 @@ fn convert_image<I>(pair: Pair<Rule>) -> Result<I, Error> where I: Element + Ext let opt_val = opt_iter.next().unwrap(); match opt_name.as_str() { "class" => image.classes_mut().push(opt_val.as_str().to_owned()), - "name" => image.names_mut().push(opt_val.as_str().to_owned()), + "name" => image.names_mut().push(NameToken(opt_val.as_str().to_owned())), "alt" => image.extra_mut().alt = Some(opt_val.as_str().to_owned()), "height" => image.extra_mut().height = Some(opt_val.parse()?), "width" => image.extra_mut().width = Some(opt_val.parse()?), diff --git a/src/parser/conversion/inline.rs b/src/parser/conversion/inline.rs index 5d75c69..d0aa524 100644 --- a/src/parser/conversion/inline.rs +++ b/src/parser/conversion/inline.rs @@ -5,7 +5,7 @@ use crate::document_tree::{ ExtraAttributes, elements as e, element_categories as c, -// attribute_types::ID, + attribute_types::{ID,NameToken}, extra_attributes as a, }; @@ -32,7 +32,9 @@ fn convert_reference(pair: Pair<Rule>) -> Result<e::Reference, Error> { match concrete.as_rule() { Rule::reference_target => { let rt_inner = concrete.into_inner().next().unwrap(); // reference_target_uq or target_name_qu - name = Some(rt_inner.as_str().to_owned()); // TODO: is this right? + //TODO: abstract + id = Some( ID(rt_inner.as_str().to_owned().replace(' ', "-"))); + name = Some(NameToken(rt_inner.as_str().to_owned())); }, Rule::reference_explicit => unimplemented!("explicit reference"), Rule::reference_auto => unimplemented!("auto reference"), |
