diff options
| author | Philipp A | 2019-12-08 20:32:54 +0100 |
|---|---|---|
| committer | Philipp A | 2019-12-09 12:03:04 +0100 |
| commit | 7018f5d3c42f18b6c83f398db9f1915361a7c679 (patch) | |
| tree | e94ad68de64c2b853e07759d4630de81762845ed | |
| parent | 1f95ebcc0e4e1393531e3d20e02d750ba0b476d6 (diff) | |
| download | rust-rst-7018f5d3c42f18b6c83f398db9f1915361a7c679.tar.bz2 | |
Fix and test substitution
| -rw-r--r-- | .travis.yml | 2 | ||||
| -rw-r--r-- | src/parser/conversion/inline.rs | 12 | ||||
| -rw-r--r-- | src/parser/tests.rs | 6 | ||||
| -rw-r--r-- | src/renderer/html_tests.rs | 9 | ||||
| -rw-r--r-- | src/rst.pest | 2 |
5 files changed, 21 insertions, 10 deletions
diff --git a/.travis.yml b/.travis.yml index 46a87c8..0f8af64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,3 +3,5 @@ language: rust cache: cargo rust: - stable +env: + - RUST_BACKTRACE=short diff --git a/src/parser/conversion/inline.rs b/src/parser/conversion/inline.rs index 52803ef..b2fffa5 100644 --- a/src/parser/conversion/inline.rs +++ b/src/parser/conversion/inline.rs @@ -21,12 +21,12 @@ use super::whitespace_normalize_name; pub fn convert_inline(pair: Pair<Rule>) -> Result<c::TextOrInlineElement, Error> { Ok(match pair.as_rule() { Rule::str | Rule::str_nested => pair.as_str().into(), - Rule::ws_newline => " ".to_owned().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::ws_newline => " ".to_owned().into(), + Rule::reference => convert_reference(pair)?, + Rule::substitution_name => 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 bad818e..a034c0e 100644 --- a/src/parser/tests.rs +++ b/src/parser/tests.rs @@ -157,12 +157,12 @@ A |subst| in-line ]), substitution_def(19, 52, [ substitution_name(23, 28), - replace(30, 52, [ paragraph(39, 52, [str(39, 52)]) ]), + replace(30, 52, [ paragraph(40, 52, [str(40, 52)]) ]), ]), substitution_def(53, 101, [ substitution_name(57, 63), - replace(65, 101, [ paragraph(74, 101, [ - str(74, 86), ws_newline(86, 87), + replace(65, 101, [ paragraph(75, 101, [ + str(75, 86), ws_newline(86, 87), str(88, 100), ]) ]), ]), diff --git a/src/renderer/html_tests.rs b/src/renderer/html_tests.rs index 62a02f6..117b2d4 100644 --- a/src/renderer/html_tests.rs +++ b/src/renderer/html_tests.rs @@ -70,6 +70,15 @@ reference and the target.</p>\ "); } +#[test] +fn test_substitution() { + check_renders_to("\ +A |subst|. + +.. |subst| replace:: text substitution +", "<p>A text substitution.</p>"); +} + /* #[test] fn test_section_hierarchy() { diff --git a/src/rst.pest b/src/rst.pest index 7c4fc0f..f3a1516 100644 --- a/src/rst.pest +++ b/src/rst.pest @@ -76,7 +76,7 @@ common_opt_name = { "class" | "name" } // Replace. A directive only usable in substitutions. -replace = { ^"replace::" ~ paragraph } +replace = { ^"replace::" ~ " "* ~ paragraph } // Image. A directive. |
