diff options
| author | Philipp A | 2020-10-31 15:39:08 +0100 |
|---|---|---|
| committer | GitHub | 2020-10-31 15:39:08 +0100 |
| commit | 8252a895ed0d23f23065be5000c45429031a2c6f (patch) | |
| tree | ea5e75cc430223f90e35bb4eaedb44f45e9b02a7 /parser/src/conversion | |
| parent | 9d506af852e253cf49095c330183075272de1f79 (diff) | |
| download | rust-rst-8252a895ed0d23f23065be5000c45429031a2c6f.tar.bz2 | |
Fix comment conversion (#27)
Diffstat (limited to 'parser/src/conversion')
| -rw-r--r-- | parser/src/conversion/block.rs | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/parser/src/conversion/block.rs b/parser/src/conversion/block.rs index f5697fc..e23cce2 100644 --- a/parser/src/conversion/block.rs +++ b/parser/src/conversion/block.rs @@ -236,23 +236,11 @@ fn convert_raw_directive(pair: Pair<Rule>) -> Result<e::Raw, Error> { Ok(raw_block) } -fn convert_comment_block(pair: Pair<Rule>) -> String { - let iter = pair.into_inner(); - let block = iter.skip(1).next().unwrap(); - let text = block.into_inner().map(|l| match l.as_rule() { - Rule::comment_line_blank => "", - Rule::comment_line => l.as_str(), - _ => unreachable!(), - }.into()).collect::<Vec<&str>>().join("\n"); - text -} - fn convert_comment(pair: Pair<Rule>) -> Result<e::Comment, Error> { - let block = pair.into_inner().skip(1).next().unwrap(); - let children = block.into_inner().map(|l| match l.as_rule() { - Rule::comment_title => String::from(l.as_str()), - Rule::comment_block => convert_comment_block(l), + let lines = pair.into_inner().map(|l| match l.as_rule() { + Rule::comment_line_blank => "\n", + Rule::comment_line => l.as_str(), _ => unreachable!(), }.into()).collect(); - Ok(e::Comment::with_children(children)) + Ok(e::Comment::with_children(lines)) } |
