aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp A2019-12-08 17:27:38 +0100
committerPhilipp A2019-12-08 17:27:38 +0100
commitf1c1422d0ae17f46999735bbb787cca188ecfa54 (patch)
tree3118224b302f65cdc6d1c9d08a86b07f0b00f3fb
parentb465cfceb7600ccf6158451a396d5c7afc2138e9 (diff)
downloadrust-rst-f1c1422d0ae17f46999735bbb787cca188ecfa54.tar.bz2
render newlines to spaces
-rw-r--r--src/parser/conversion/inline.rs1
-rw-r--r--src/parser/tests.rs9
-rw-r--r--src/renderer/html_tests.rs2
-rw-r--r--src/rst.pest5
4 files changed, 11 insertions, 6 deletions
diff --git a/src/parser/conversion/inline.rs b/src/parser/conversion/inline.rs
index 297680a..bdabbf0 100644
--- a/src/parser/conversion/inline.rs
+++ b/src/parser/conversion/inline.rs
@@ -21,6 +21,7 @@ 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(),
diff --git a/src/parser/tests.rs b/src/parser/tests.rs
index e161108..bad818e 100644
--- a/src/parser/tests.rs
+++ b/src/parser/tests.rs
@@ -161,7 +161,10 @@ A |subst| in-line
]),
substitution_def(53, 101, [
substitution_name(57, 63),
- replace(65, 101, [ paragraph(74, 101, [str(74, 86), str(88, 100)]) ]),
+ replace(65, 101, [ paragraph(74, 101, [
+ str(74, 86), ws_newline(86, 87),
+ str(88, 100),
+ ]) ]),
]),
]
};
@@ -222,8 +225,8 @@ paragraph
bullet_item(21, 131, [
line(24, 31, [ str(24, 30) ]),
paragraph(34, 74, [
- str(34, 43),
- str(47, 58),
+ str(34, 43), ws_newline(43, 44),
+ str(47, 58), ws_newline(58, 59),
str(62, 73),
]),
bullet_list(77, 131, [
diff --git a/src/renderer/html_tests.rs b/src/renderer/html_tests.rs
index 30fc1b1..62a02f6 100644
--- a/src/renderer/html_tests.rs
+++ b/src/renderer/html_tests.rs
@@ -65,7 +65,7 @@ reference and the target.
.. _`named reference`: http://www.test.com/test_url
", "\
-<p>A simple <a href=\"http://www.test.com/test_url\">named reference</a> with stuff in between the
+<p>A simple <a href=\"http://www.test.com/test_url\">named reference</a> with stuff in between the \
reference and the target.</p>\
");
}
diff --git a/src/rst.pest b/src/rst.pest
index 1034d03..7c4fc0f 100644
--- a/src/rst.pest
+++ b/src/rst.pest
@@ -103,8 +103,9 @@ admonition_content = _{ PEEK[..-1] ~ PUSH(" " ~ POP) ~ hanging_block ~ block* }
line = { !marker ~ inline+ ~ NEWLINE }
blank_line = _{ !marker ~ !inline ~ " "* ~ NEWLINE }
-inlines = _{ !marker ~ inline+ ~ ( NEWLINE ~ (PEEK[..] ~ !marker ~ inline+ ~ NEWLINE)+ )? }
-inline = _{ inline_special | str }
+inlines = _{ !marker ~ inline+ ~ ( ( ws_newline ~ PEEK[..] ~ !marker ~ inline+ )+ ~ NEWLINE )? }
+ws_newline = { NEWLINE }
+inline = _{ inline_special | str }
inline_special = _{
reference
| substitution_ref