Permalink
Browse files

Multistring format correctly

  • Loading branch information...
1 parent f93f6ab commit 1ed3e21fc38c1bf542624032ffe46517d5af9f5f @philcali committed Jul 27, 2012
Showing with 19 additions and 11 deletions.
  1. +7 −7 core/src/main/scala/parsers.scala
  2. +12 −4 markdown/src/test/scala/markdown.scala
@@ -30,14 +30,14 @@ trait LmxmlParsers extends RegexParsers {
s.substring(1, s.length -1)
}
- // To be replaced by multiLine definition below
- lazy val strWrapper = "```" ~> rep1(everything) <~ allwp ~ "```" ^^ {
- ls => ls.reduceLeft(_ + _)
+ private def multiStrFormat(ls: List[String]) = ls.reduceLeft { (l, r) =>
+ l + whiteSpace.findPrefixOf(r).map(_ => " " + r).getOrElse(r)
}
- lazy val multiLine = "~~~" ~> rep1(allText) <~ allwp ~ "~~~" ^^ {
- ls => ls.reduceLeft(_ + _)
- }
+ // To be replaced by multiLine definition below
+ lazy val strWrapper = "```" ~> rep1(everything) <~ allwp ~ "```" ^^ (multiStrFormat)
+
+ lazy val multiLine = "~~~" ~> rep1(allText) <~ allwp ~ "~~~" ^^ (multiStrFormat)
lazy val commentNode: Parser[TopLevel] = "//" ^^ { _ => CommentNode(_) }
@@ -101,7 +101,7 @@ trait LmxmlParsers extends RegexParsers {
}
}
- def spaces(n: Int) = """\s{%d}""".format(n).r
+ def spaces(n: Int) = """[ ]{%d}""".format(n).r
def descending(d: Int): Parser[Any] =
opt(spaces(d)) ~> topLevel ~ rep(descending(d + increment) | topLevel)
@@ -16,9 +16,14 @@ I'm talking with _emphasis_!
Did you __hear__ me!?
- - Work
- - Fun
- - Play
+- Work
+- Fun
+- Play
+
+I want:
+
+ code
+ talk
```
"""
@@ -27,7 +32,10 @@ Did you __hear__ me!?
</p><ul><li>Work
</li><li>Fun
</li><li>Play
-</li></ul>"""
+</li></ul><p>I want:
+</p><pre><code>code
+talk
+</code></pre>"""
"Markdown mixin" should "be able to parse mardown nodes" in {

0 comments on commit 1ed3e21

Please sign in to comment.